Wang Chun <[email protected]> added the comment:
This is my test on another faster machine.
$ cat test.py
import sys, time, uuid
N = int(sys.argv[1])
t = time.time()
for x in xrange(N):
uuid.uuid1()
print('%.3f microseconds' % ((time.time() - t) * 1000000.0 / N))
$ cat test.c
#include <stdio.h>
#include <sys/time.h>
#include <uuid/uuid.h>
int main(int argc, char *argv[])
{
int i, n;
double t1, t2;
uuid_t uuid;
struct timeval t;
struct timezone tz;
sscanf(argv[1], "%d", &n);
gettimeofday(&t, &tz);
t1 = (double)t.tv_sec + (double)t.tv_usec / 1000000.0;
for (i = 0; i < n; i++) {
uuid_generate_time(uuid);
}
gettimeofday(&t, &tz);
t2 = (double)t.tv_sec + (double)t.tv_usec / 1000000.0;
printf("%.3f microseconds\n", (t2 - t1) * 1000000.0 / n);
return 0;
}
$ gcc -l uuid -o test test.c
$ python test.py 50000
25.944 microseconds
$ python test.py 200000
25.810 microseconds
$ python test.py 1000000
25.865 microseconds
$ ./test 50000
0.214 microseconds
$ ./test 200000
0.214 microseconds
$ ./test 1000000
0.212 microseconds
$
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue5885>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com