Я пытаюсь перенести свой код Python на C, но перед этим я провел тест производительности, но, похоже, он не улучшил производительность.
Сначала программа на C:
#include <stdio.h>
main ()
{
printf("hello world \n");
}
[root@server c]$ gcc test.c
[root@server c]$ time ./a.out
hello world
real 0m0.001s
user 0m0.000s
sys 0m0.000s
Вторая программа Python:
#!/usr/bin/env python
print "hello world \n"
[root@server c]$ time python test.py
hello world
real 0m0.024s
user 0m0.020s
sys 0m0.003s
Третья версия Cython ...
test.py
print "hello world \n"
[root@server c]$ cython --embed test.py
[root@server c]$ gcc $CFLAGS -I/usr/include/python2.6 -o test test.c -lpython2.6 -lpthread -lm -lutil -ldl
[root@server c]$ time ./test
hello world
real 0m0.024s
user 0m0.019s
sys 0m0.004s
Так что мне кажется, что Cython действительно не улучшил какую-либо производительность.Любые идеи, почему и как я могу это исправить, так как Cython должен заставить код Python работать быстрее?