Prime interpreter speed test (surprising result)
Good morning,
I am running some deeper simulations in P8 and noted that the CPU grind was pretty fast. I was surprised at this and ran a simple side-by-side with compiled C on a simple summation test. I found that the slowdown ratio was only about x25. In similar tests, I have found Python to be about x200 to x500. I'd be interested to know how P8 has achieved this. Perhaps the developers could comment.
Here is the C++ project
/* time example */
#include <stdio.h> /* printf */
#include <time.h> /* time_t, struct tm, difftime, time, mktime */
#include <iostream>
double F_SUM()
{
double SUM = 0;
for (long i = 0; i < 1000000000; i++)
{
SUM += i;
}
return SUM;
}
int main()
{
//clock_t clock(void) returns the number of clock ticks elapsed since the program was launched.To get the number of seconds used by the CPU you will need to divide by CLOCKS_PER_SEC
clock_t t_STR;
clock_t t_END;
double dt_CPU;
// Recording the starting clock tick
t_STR = clock();
double SUM = F_SUM();
// Recording the end clock tick.
t_END = clock();
// Calculating total time taken by the program.
dt_CPU = double(t_END - t_STR) / double(CLOCKS_PER_SEC);
std::cout << "Time taken by program is : " << dt_CPU << ", SUM = " << SUM;
return 0;
}
I went back and did a comparable Python test which shows Python is about x4 slower than P8:
Here is the Python code:
import time
t_STR = time.time()
SUM = 0
N = 1000000000
for i in range(N):
SUM += i
dt_CPU = time.time()- t_STR
print(SUM, dt_CPU)
Results:

Regards
