[英]Changing execution time of program
I have a program that takes a text file, read each line and then insert each line to a list. 我有一个程序需要一个文本文件,读取每一行,然后将每一行插入到列表中。 I used
stopwatch
to calculate time of execution. 我使用
stopwatch
来计算执行时间。 But there is some droll result! 但是有一些拖延的结果! I'll give various elapsed time when I run the program each time (difference is about 1 or 2 seconds).
每次运行程序时,我都会给出各种经过的时间(差异约为1或2秒)。
The text file involves 3 million URLs. 该文本文件包含300万个URL。
Any idea??! 任何想法??!
The processing time for a set of commands depends on (but is not limited to): 一组命令的处理时间取决于(但不限于):
I could go on for days here. 我可以在这里继续几天。 The point is (as TheifMaster said), there are so many variables at stake here that it would be a miracle if your code had the same time for any 2 runs!
关键是(如TheifMaster所说),这里有这么多的变量危在旦夕,如果您的代码有两次运行相同的时间,那将是一个奇迹! It's the "every snowflake is different" methodology.
这是“每一个雪花都是不同的”方法。 With so many environment variables, no 2 runs will be the same.
由于环境变量太多,因此两次运行都不会相同。
Don't fret on time differences, just focus on getting the average time as low as you need to. 不要为时差而烦恼,只需专注于使平均时间尽可能短。
某些波动是完全正常的,尤其是当代码涉及IO(例如读取文件)时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.