107transfer
ETUDE DE PERFORMANCE
PYTHON VERSUS C
SIMPLE CODE BENCHMARK
{ x + y = 14
{ x^2 + y^2 = 100Python
C
1 │ #!/usr/bin/python
2 │ x = 1
3 │ while x <= 14:
4 │ y = 14 - x
5 │ print (x, y)
6 │ if x**2 + y**2 == 100:
7 │ print ("match")
8 │ x = x + 1
./test.py 0.02s user 0.00s system 98%
cpu 0.020 total#include <stdio.h>
int main()
{
int x, y, t;
for (x = 1; x <= 14; x++)
{
y = 14 - x;
printf("%d|%d\n", x, y);
if ((x*x) + (y*y) == 100)
printf("match\n");
}
return 0;
}
0.00s user 0.00s system 0%
cpu 0.001 totalSTRESS METHOD
PYTHON
C
1 │ #include <stdio.h>
2 │
3 │ int main ()
4 │ {
5 │ int i;
6 │ for (i = 0; i < 1000000; i++)
7 │ printf ("%d\n", i);
8 │ return 0;
9 │ }
./test2_c 0.18s user 0.82s system 5%
cpu 19.216 total
1 │ #!/usr/bin/python
2 │ for i in range(0, 1000000):
3 │ print (i)
./test2_py 1.75s user 1.13s system 14%
cpu 19.301 totalCONCLUSION
BETWEEN C and PYTHON
The C is slightly faster.
The C consumes less CPU.
Gestion des PARAMETRES et options
regex methods
OPTIMISATION
HORNER METHOD
StabLE METHOD
UNITARY TEST BEFORE PUSH
thank you for watching
107transfer
By bonett_w
107transfer
Speedtest and stress C versus Python 3.0
- 613