New submission from Jim Kelly <[email protected]>:

So I had mentioned on twitter that I was seeing that CPython was significantly 
faster than PyPy in some performance testing I was doing.  Essentially I was 
just 
pushing data as fast as possible through this app to get a sense of its 
throughput 
limits.  Romain Guillebert requested I file a bug.

I tracked this down a bit, and it seems to me the issue was actually the 
scaffolding around my tests.  I basically had a set of sample data and was 
runnign 
a while look for a set period of time using datetime, then randomly selected 
sample data and ran it through my program, rinse, repeat.

At any rate, looking at CProfile, it seems that datetime calls are taking a 
long 
time to execute.  I tried this both on 1.9 and 2.0beta2, and this is in 
comparison 
to CPython 2.7.2.  I've attached the simple test case I created.  You'll note 
the 
"datetime.datetime.now() < (startTime + datetime.timedelta(minutes=2))" call is 
no 
longer part of the while loop, so as to make it more apparent what was running 
longer, while still executing it.  

Here are the various results.  As you can see 2 beta2 is substantially faster 
than 
1.9, but both are slower than CPython.  Thanks!

CPython 2.7.2:
         1000003 function calls in 4.818 seconds

   Ordered by: cumulative time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    2.878    2.878    4.818    4.818 mytest.py:6(TestFunc)
  1000001    1.940    0.000    1.940    0.000 {built-in method now}
        1    0.000    0.000    0.000    0.000 {method 'disable' of 
'_lsprof.Profiler' objects}

PyPy 1.9:
         87000029 function calls in 179.627 seconds

   Ordered by: cumulative time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.489    0.489  179.627  179.627 mytest.py:6(TestFunc)
  1000001    1.039    0.000   79.641    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:1543(now)
  1000001    4.021    0.000   77.711    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:1492(fromtimestamp)
  1000000   44.124    0.000   69.953    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:446(__new__)
  2000001    5.676    0.000   48.972    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:1445(__new__)
  1000001    5.792    0.000   44.650    0.000 {time.localtime}
  1000001   30.022    0.000   38.858    0.000 /Users/pypy/buildslave/pypy-c-jit-
macosx-x86-64/build/lib_pypy/_structseq.py:71(structseq_new)
  2000001   27.699    0.000   38.829    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:759(__new__)
  1000000    1.181    0.000   26.775    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:1838(__add__)
 33000008   16.083    0.000   16.083    0.000 {isinstance}
  3000001   10.666    0.000   10.666    0.000 {method '__new__' of 'type' 
objects}
  9000000    5.756    0.000    5.756    0.000 {abs}
  1000001    5.087    0.000    5.087    0.000 {method '__setattr__' of 'object' 
objects}
  6000000    4.154    0.000    4.154    0.000 {divmod}
  2000001    2.753    0.000    4.092    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:285(_check_time_fields)
  2000001    3.785    0.000    3.785    0.000 {round}
  1000001    3.431    0.000    3.431    0.000 {method '__new__' of 
'_structseq.structseqtype' objects}
  1000000    0.516    0.000    2.769    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:1783(__lt__)
  2000001    1.699    0.000    2.424    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:273(_check_date_fields)
  1000000    0.647    0.000    2.065    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:1807(_cmp)
  1000001    2.009    0.000    2.009    0.000 {min}
  1000000    1.219    0.000    1.219    0.000 {cmp}
  1000001    0.891    0.000    0.891    0.000 {time.time}
  1000000    0.403    0.000    0.624    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:345(__init__)
  2000002    0.318    0.000    0.318    0.000 {len}
  3000001    0.048    0.000    0.048    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:56(_days_in_month)
  3000002    0.043    0.000    0.043    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:298(_check_tzinfo_arg)
  1000000    0.020    0.000    0.020    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:594(seconds)
  1000000    0.020    0.000    0.020    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:599(microseconds)
  1000000    0.019    0.000    0.019    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:589(days)
  1000000    0.019    0.000    0.019    0.000 
/usr/local/Cellar/pypy/1.9/lib_pypy/datetime.py:957(_checkOverflow)
        1    0.000    0.000    0.000    0.000 {method 'disable' of 
'_lsprof.Profiler' objects}

PyPy 2 beta2:
         100000037 function calls in 97.047 seconds

   Ordered by: cumulative time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.355    0.355   97.047   97.047 mytest.py:6(TestFunc)
  1000000   42.643    0.000   67.528    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:436(__new__)
  1000001    0.878    0.000   18.800    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:1534(now)
  1000001    1.575    0.000   17.231    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:1489(fromtimestamp)
 32000008   15.039    0.000   15.039    0.000 {isinstance}
  2000001    4.595    0.000   13.873    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:1441(__new__)
  1000000    1.085    0.000    9.230    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:1841(__add__)
  1000001    2.137    0.000    7.435    0.000 {time.localtime}
 14000007    3.853    0.000    6.044    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:272(_check_int_field)
  1000001    3.542    0.000    5.297    0.000 /Users/pypy/buildslave/pypy-c-jit-
macosx-x86-64/build/lib_pypy/_structseq.py:70(structseq_new)
  8000000    4.659    0.000    4.659    0.000 {abs}
  2000001    1.071    0.000    4.527    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:300(_check_time_fields)
  7000001    4.163    0.000    4.163    0.000 {divmod}
  3000001    3.951    0.000    3.951    0.000 {method '__new__' of 'type' 
objects}
  2000001    0.389    0.000    3.012    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:287(_check_date_fields)
  2000001    2.525    0.000    2.960    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:27(_round)
  1000000    0.349    0.000    1.133    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:1787(__lt__)
  1000001    0.777    0.000    0.777    0.000 {method '__new__' of 
'_structseq.structseqtype' objects}
  1000001    0.699    0.000    0.699    0.000 {method '__setattr__' of 'object' 
objects}
  1000001    0.692    0.000    0.692    0.000 {time.time}
  1000000    0.381    0.000    0.614    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:360(__init__)
  1000000    0.378    0.000    0.559    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:1811(_cmp)
  2000001    0.435    0.000    0.435    0.000 {math.floor}
  1000001    0.404    0.000    0.404    0.000 {min}
  2000002    0.280    0.000    0.280    0.000 {len}
  3000001    0.055    0.000    0.055    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:61(_days_in_month)
  3000002    0.038    0.000    0.038    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:315(_check_tzinfo_arg)
  1000000    0.024    0.000    0.024    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:24(_cmp)
  1000000    0.020    0.000    0.020    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:575(seconds)
  1000000    0.018    0.000    0.018    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:946(_checkOverflow)
  1000000    0.018    0.000    0.018    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:580(microseconds)
  1000000    0.017    0.000    0.017    0.000 /usr/local/pypy-2.0-
beta2/lib_pypy/datetime.py:570(days)
        1    0.000    0.000    0.000    0.000 {method 'disable' of 
'_lsprof.Profiler' objects}

----------
files: mytest.py
messages: 5674
nosy: jkelly, pypy-issue
priority: performance bug
release: 2.0
status: unread
title: datetime issues in CPython vs PyPy

________________________________________
PyPy bug tracker <[email protected]>
<https://bugs.pypy.org/issue1477>
________________________________________
_______________________________________________
pypy-issue mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-issue

Reply via email to