(* Print the number of available Parallel Threads *)
Print["Total number of cores used by Mathematica by default ",$ProcessorCount];

(* This creates and runs compiled function sequentially *)
arg = Range[ -50., 50, 0.02];
cS = Compile[{{x}},
Module[{sum = 1.0, inc = 1.0}, 
Do[inc = inc*x/i; sum = sum + inc, {i, 10000}]; sum],
RuntimeAttributes -> {Listable}, Parallelization -> False]; 
{T1,result1}=AbsoluteTiming[cS[arg]]; 
Print["Time to execute the sequential execution: ", T1];

(* This creates an equivalent function that will run in parallel *)
cP = Compile[{{x}},
Module[{sum = 1.0, inc = 1.0}, 
Do[inc = inc*x/i; sum = sum + inc, {i, 10000}]; sum],
RuntimeAttributes -> {Listable}, Parallelization -> True];
{T2,result2}=AbsoluteTiming[cP[arg]];
Print["Time to execute the parallel execution: ", T2];

Exit[];

