Skip to content

Instantly share code, notes, and snippets.

@hastebrot
Created August 26, 2011 18:33
Show Gist options
  • Save hastebrot/1174081 to your computer and use it in GitHub Desktop.
Save hastebrot/1174081 to your computer and use it in GitHub Desktop.
division performance
#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;
}
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)
#!/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