Why do these benchmarks NOT saturate the CPU.

0

I ran two trivial benchmarks in Powershell and C. I ran this on reasonably well endowed i7-2600 with 16 Gig Win 7 Pro.

Both ran using two of the 8 cores (really 4 cores dual hyper threaded) and ran very peaky ranging over 40% to 70% utilization over its run time (30 to 60 seconds). The rest of the system was quiet but on a domain and both dev environments were open and so was Firefox. The background activity before and after the runs was using 1.5% to 2.5% of the total CPU availability.

What is going on in windows that limits these compute bound processes from pinning the CPU on at least the cores they run on.

This was for a on the fly demo I did and expected the cpu to pin at 100%.

Powershell

$a = 1  
"Starting Loop"
get-date
DO
{
 $a++
} While ($a -le 50000000)
get-date

C

#include <stdio.h>
#include <time.h>

int main (void) {

  long long a;
  time_t mytime;
  mytime = time(NULL);
  printf(ctime(&mytime));
  /* for loop execution */
  for( a = 1; a < 100000000000; a = a + 1 ){

  }
  mytime = time(NULL);
  printf(ctime(&mytime));

 return 0;
}    

Prosaic Hacker

Posted 2015-12-08T21:34:09.033

Reputation: 91

this kind of line: printf(ctime(&mytime)); will cause the compiler to raise a warning message (on gcc, when using: -Wall -Wextra -pedantic) suggest using: printf("%s", ctime(&mytime)); – user3629249 – 2015-12-09T04:17:01.443

on my computer, a 4 core amd64, running ubuntu linux 14.04, with top running in a separate terminal, the program shows 99.9 to 100 percent CPU. I would expect single core CPUs to run a lower percentage as the OS (and the second terminal running top) take up some percentage of the CPU cycles of a single core – user3629249 – 2015-12-09T04:23:34.673

I suspect what your seeing is the windows really sucks the CPU cycles, which is why I can type, on a 4 core cpu, running Vista, and Windows cannot keep up with my typing to echo characters to the screen – user3629249 – 2015-12-09T04:25:49.607

On my computer, 4ghz 4 core amd64, 8 gig RAM, running ubuntu linux 14.04, the posted code took 3 minutes 46 seconds when compiled with no optimization – user3629249 – 2015-12-09T04:28:56.887

The C code would have only been ran in a single thread. It does not implement any code to launch additional threads. – Ramhound – 2015-12-09T13:46:37.430

Used Pelles C. The "top" results above were what I would have expected. The run time is not the issue, why did it not pin a single core during the run time is the issue. I never expected it run in more than 1 thread. – Prosaic Hacker – 2015-12-11T04:07:48.000

No answers