Created
December 16, 2013 06:52
-
-
Save jack128/7983236 to your computer and use it in GitHub Desktop.
javascript vs Delphi perf test. see here delphi code https://forums.embarcadero.com/thread.jspa?threadID=74930
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function itg (x) { return x*x; } | |
var vp = 50000; | |
var np = 0; | |
var snp = np; | |
var step = 0.0001; | |
var sum = 0; | |
console.log('Integral calculations...'); | |
var cnt1 = Date.now(); | |
while (np + step < vp) { | |
//sum = sum + (itg(np) + itg(np + step)) / 2*step; | |
sum = sum + ((np*np + (np + step)*(np + step))) / 2 * step; | |
np = np + step; | |
} | |
var cnt2 = Date.now(); | |
var cnt3 = cnt2 - cnt1; | |
console.log('Integral from ' + snp + ' to ' + vp + | |
' step ' + step + ' is equal ' + sum + | |
'Difference: ' + (cnt3 / 1000) + ' seconds'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment