Created
August 26, 2011 18:33
-
-
Save hastebrot/1174081 to your computer and use it in GitHub Desktop.
division performance
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
#include <stdio.h> | |
#include <time.h> | |
int main(void) { | |
clock_t start, end; | |
double duration; | |
int counter = 0; | |
float x; | |
start = clock(); | |
while (counter < 100000000) { | |
counter++; | |
x = counter / 2; | |
} | |
end = clock(); | |
duration = (double)(end - start) / (double)CLOCKS_PER_SEC; | |
printf("%f\n", duration); | |
return 0; | |
} |
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
var start = new Date().getTime() | |
var x, counter = 0 | |
while (counter < 100000000) { | |
counter += 1 | |
x = counter / 2 | |
} | |
var duration = (new Date().getTime() - start) / 1000 | |
console.log(duration) |
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
#!/usr/bin/python | |
import time | |
start = time.time() | |
counter = 0 | |
while (counter < 100000000): | |
counter += 1 | |
x = counter / 2 | |
duration = time.time() - start | |
print(duration) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment