visual studio - why the sum of "Functions With Most Individual Work" can't be more than 100%? -
i'm using vs2010 built-in profilier application contains 3 threads. 1 of thread simple:
while (true) if (something) { // blah blah, fast , occuring thing } thread.sleep(1000); }
visual studio reports thread.sleep takes 36% of program time. question "why not ~100% of time?" why main
methods takes 40% of time, inside method durring application execution start end.
do profiler devides result number of threads?
on thread i've observed method takes 34% of time. mean? mean works 34% of time or works time?
in opinion if have 3 threads run in parallel, , if sum methods time should 300% (if application runs 10 seconds example, means each thread runs 10 seconds, , if there 3 threads - 30 seconds totally)
the question what measuring , how it. question i'm unable repeat experience actually...
thread.sleep()
call takes small amount of time itself. task call native function winapi command scheduler (responsible dividing processor time between threads) user thread called should not scheduled next second @ all. after thread doesn't receive processor time until second over.
but thread not takes bit of processor time in state. i'm not sure how situation reported profiler.
here code experimenting with:
internal class program { private static int x = 0; private static void a() { // have in profiler here console.writeline("a"); } private static void main(string[] args) { var t = new thread(() => { while (x == 0) thread.memorybarrier(); }); t.start(); while (true) { if (datetime.now.millisecond%3 == 0) a(); thread.sleep(1000); } } }
Comments
Post a Comment