User Tools

Site Tools


notes:comporg:projects:pnc1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:comporg:projects:pnc1 [2018/02/01 02:49] – [Project: IMPLEMENTATIONS AND OPTIMIZATIONS - PRIME NUMBER COMPUTATION (pnc1)] bstrong2notes:comporg:projects:pnc1 [2018/02/06 13:41] (current) – [Project: IMPLEMENTATIONS AND OPTIMIZATIONS - PRIME NUMBER COMPUTATION (pnc1)] bstrong2
Line 69: Line 69:
  
 See how it runs with **pncrun** for each compiler. \\ See how it runs with **pncrun** for each compiler. \\
 +
 +**Command Line Arguments:**\\
 +Just a friendly reminder that when command line arguments are passed they are usually (I don't know of any cases when they aren't actually) passed as strings. Make sure to cast it from a string to whichever data type it is supposed to be. 
 +
 +
 +**Go** \\
 +<code> upBound, err = strconv.Atoi(os.Args[1]) </code>
 +
 +**Lua** \\
 +<code> local upBound = tonumber(arg[1])</code>
 +
 +**Python3**\\
 +I don't know for sure if this works for Python2
 +<code> upBound = int(sys.argv[1]) </code>
 +
 +
  
 **To compile a go program:** \\ **To compile a go program:** \\
Line 146: Line 162:
 require "benchmark" require "benchmark"
  
-time = Benchmark.realtime.do+time = Benchmark.realtime do
  
 // insert prime calculation code here // insert prime calculation code here
Line 193: Line 209:
 System.out.println(totalTime); System.out.println(totalTime);
 </code> </code>
-(You can change the output format)+(You can change the output format as this will give you nano seconds) 
 +Or if you don't want to deal with nanoseconds you can use "System.currentTimeMillis()" instead
  
  
Line 242: Line 259:
  
 <code> <code>
-startM = new Date().getMilliseconds(); +var start = new Date().getTime(); 
-startS = new Date().getSeconds();+
  
 -Pnc1 code- -Pnc1 code-
  
-endM = new Date().getMilliseconds(); +var end = new Date().getTime(); 
-endS new Date().getSeconds(); + 
-totalTime = endM - startM; +var time = (end-start)/1000;
-seconds = endS - startS;+
  
-totalTime /= 10000; +console.log(time);
-totalTime += seconds; +
-console.log(totalTime);+
 </code> </code>
  
notes/comporg/projects/pnc1.1517453351.txt.gz · Last modified: 2018/02/01 02:49 by bstrong2