Hi, anybody here who are good at parallel processing in Rhino Python?

I made a simple test but the results doesn’t seem right.

I have tried to make a script that lets the cpu calculate n += 1 for 1 second in default one core mode and THEN set up 500 tasks that runs for 1 second IF time ran is less than 1 second. (That should result in x number of tasks that ran for 1 second and the rest of the 500 to be returned as

```
import System.Threading.Tasks as tasks
import rhinoscriptsyntax as rs
import time
import random
def calculateSinglecore(time2Run):
time1=time.time()
i = 0
while True:
i += 1
if time.time()-time1 > time2Run:
break
return int(i/time2Run)
def calculateMulticore(time2Run):
points=range(500)
results=range(500)
timeStart=time.time()
def calculate(i):
n=0
while time.time()-timeStart < time2Run:
n += 1
results[i] = n
tasks.Parallel.ForEach(xrange(len(points)), calculate)
results = [x for x in results if x != 0]
print len(results), "Threads started"
print results
### Add up all calculations
Total = sum(results)
### measure actual time used and divide sum to get calculations within one second
runTime=time.time()-timeStart
result = int(Total/runTime)
return result
test1 = calculateSinglecore(1)
print test1,"calculations per second in serial processing"
test2 = calculateMulticore(1)
print test2,"calculations per second in parallel processing"
print round(test2/test1,2), "times faster in parallel"
```

My results on a 12 core system is:

**482991 calculations per second in serial processing**

**25 Threads started**

**[45542, 38472, 44854, 45001, 43605, 43845, 48035, 45841, 45119, 43848, 47106, 47589, 36292, 41124, 44695, 43304, 38177, 49657, 47278, 41905, 46837, 44746, 46086, 50670, 45309]**

**1105097 calculations per second in parallel processing**

**2.29 times faster in parallel**

NOTE: Some thing I don’t understand is that if I set the number of tasks (points and results) to 2 instead of 500 I get the same result… and each task has a higher count…