In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "what is the impact of the number of classes in C# programs on program startup". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "what is the impact of the number of classes in C# programs on program startup".
Preface
Recently, I wrote tens of thousands of lines of code in the project, and my partner was worried that it would slow down the start of the program, so I came to do the test. This scum uses a code creator to create 1000 junk files, all of which are simple. I put these files in a console project without making any references, and then use the dotTrace test console to start the time.
I also wrote a blank console project that didn't even have output. Look at the code.
Using System;using System.Diagnostics;namespace KejerbopaNekereyeresereJemayRouxouqou {class Program {static void Main (string [] args) {}
This should be the fastest console code, so use dotTrace to attach and debug the project
Additional debugging shows that none of the running time is the time of your own code, and the total time is that 138ms actually takes less time to run. The test time of each person's device will be different, and the value of each time will be different.
I then ran it twice to collect the run time of the empty console window.
Empty console window run time
First time: 138ms
The second time: 110ms
The third time: 116ms
It's easy to write a blank class. I used the following code to create a random class name.
Class WhairchooHerdo {public string LemgeDowbovou () {var zarwallsayKeesar = (char) _ ran.Next ('Aids,' Z' + 1); var lardurDairlel = new StringBuilder (); lardurDairlel.Append (zarwallsayKeesar); for (int I = 0; I
< 5; i++) { lardurDairlel.Append((char)_ran.Next('a', 'z')); } return lardurDairlel.ToString(); } private Random _ran = new Random(); } 然后使用下面代码创建随机的类 private static void RelawcereMirouxayTibe() { var terebawbemTitirear = new WhairchooHerdo(); for (int i = 0; i < 1000; i++) { var pereviCirsir = terebawbemTitirear.LemgeDowbovou(); var nemhaSibemnoosa = $@"using System;using System.Collections.Generic;using System.Text;namespace LecuryouWuruhempa{{ class {pereviCirsir} {{ public string Foo {{ get; set; }} }}}}"; var jisqeCorenerairTurpalhee = new DirectoryInfo("林德熙临时文件"); jisqeCorenerairTurpalhee.Create(); File.WriteAllText(Path.Combine(jisqeCorenerairTurpalhee.FullName, pereviCirsir + ".cs"), nemhaSibemnoosa); } } 这样就可以创建 1000 个类,创建一个空白的控制台项目,引用这些类 然后运行一个有1000个类的空白控制台项目,第一次运行的时间居然是 67ms 十分少I also ran it three times and collected the following information
Empty console window run time for 1000 classes
First time: 67ms
The second time: 102ms
The third time: 117ms
So if a class is not referenced, even if there are many classes in a project, it has little effect on the startup of the software.
Then it is the same as before, but changed to empty console project reference dll this dll has 1000 classes
If the blank project is the dll referenced by KejerbopaNekereyeresereJemayRouxouqou.exe or MeeLearlerepeda.exe, you can see that there are 1000 classes or relatively large ones.
Also tested three times.
Dll empty console window run time referencing 1000 classes
First time: 113ms
The second time: 103ms
The third time: 117ms
As you can see from the above data, there is almost no effect.
These are all the contents of the article "what is the impact of the number of classes in C# programs on program startup". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.