在PyPy下,测试速度慢了4倍

时间:2015-06-06 06:41:04

标签: python pypy

我正在使用nose2运行我项目的测试:

#!/bin/sh
nose2 --config=tests/nose2.cfg "$@"

在CPython测试下,运行速度比PyPy快4倍:

Python 2.7.8 (default, Oct 20 2014, 15:05:19) 
[GCC 4.9.1] on linux2
...
Ran 58 tests in 25.369s

Python 2.7.9 (2.5.1+dfsg-1~ppa1+ubuntu14.04, Mar 27 2015, 19:19:42)
[PyPy 2.5.1 with GCC 4.8.2] on linux2
...
Ran 58 tests in 100.854s

可能是什么原因?

有没有办法在某些标准路径上使用环境变量或配置文件来调整PyPy配置?因为在我的情况下,我正在运行nose引导脚本,我无法控制PyPy的命令行选项。

以下是一项具体测试:

         1272695 function calls (1261234 primitive calls) in 1.165 seconds

   Ordered by: cumulative time, internal time, call count
   List reduced from 1224 to 40 due to restriction <40>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    1.171    1.171 test_progress.py:37(test_progress)
       15    0.000    0.000    1.169    0.078 __init__.py:52(api_request)
       15    0.000    0.000    1.160    0.077 __init__.py:46(request)
       15    0.000    0.000    1.152    0.077 test.py:695(open)
       15    0.000    0.000    1.150    0.077 test.py:655(run_wsgi_app)
       15    0.000    0.000    1.144    0.076 test.py:828(run_wsgi_app)
       15    0.000    0.000    1.144    0.076 application.py:101(__call__)
       15    0.000    0.000    1.138    0.076 sessions.py:329(__call__)
       15    0.000    0.000    1.071    0.071 course_object.py:14(__call__)
       15    0.000    0.000    1.005    0.067 user_auth.py:7(__call__)
       15    0.000    0.000    0.938    0.063 application.py:27(application)
       15    0.000    0.000    0.938    0.063 application.py:81(wsgi_app)
       15    0.000    0.000    0.876    0.058 ember_backend.py:188(__call__)
       15    0.000    0.000    0.875    0.058 ember_backend.py:233(handle_request)
      176    0.002    0.000    0.738    0.004 __init__.py:42(instrumented_method)
      176    0.003    0.000    0.623    0.004 __init__.py:58(get_stack)
      176    0.000    0.000    0.619    0.004 inspect.py:1053(stack)
      176    0.010    0.000    0.619    0.004 inspect.py:1026(getouterframes)
      294    0.001    0.000    0.614    0.002 cursor.py:1072(next)
      248    0.001    0.000    0.612    0.002 cursor.py:998(_refresh)
      144    0.002    0.000    0.608    0.004 cursor.py:912(__send_message)
     7248    0.041    0.000    0.607    0.000 inspect.py:988(getframeinfo)
        8    0.000    0.000    0.544    0.068 test_progress.py:31(get_progress_data)
        4    0.000    0.000    0.529    0.132 test_progress.py:25(finish_item)
      249    0.001    0.000    0.511    0.002 base.py:1131(next)
        7    0.000    0.000    0.449    0.064 ember_backend.py:240(_handle_request)
        8    0.000    0.000    0.420    0.053 ember_backend.py:307(_handle_request)
        8    0.000    0.000    0.420    0.053 user_state.py:13(list)
        8    0.001    0.000    0.407    0.051 user_progress.py:28(update_progress)
        4    0.000    0.000    0.397    0.099 entity.py:253(post)
     7248    0.051    0.000    0.362    0.000 inspect.py:518(findsource)
    14532    0.083    0.000    0.332    0.000 inspect.py:440(getsourcefile)
    92/63    0.000    0.000    0.308    0.005 objects.py:22(__get__)
       61    0.001    0.000    0.304    0.005 base.py:168(get)
      139    0.000    0.000    0.250    0.002 queryset.py:65(_iter_results)
       51    0.001    0.000    0.249    0.005 queryset.py:83(_populate_cache)
       29    0.000    0.000    0.220    0.008 __init__.py:81(save)
       29    0.001    0.000    0.219    0.008 document.py:181(save)
    21780    0.051    0.000    0.140    0.000 inspect.py:398(getfile)
       32    0.002    0.000    0.139    0.004 {pymongo._cmessage._do_batched_write_command}

与PyPy:

         6037905 function calls (6012014 primitive calls) in 7.475 seconds

   Ordered by: cumulative time, internal time, call count
   List reduced from 1354 to 40 due to restriction <40>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    7.960    7.960 test_progress.py:37(test_progress)
       15    0.000    0.000    7.948    0.530 __init__.py:52(api_request)
       15    0.000    0.000    7.873    0.525 __init__.py:46(request)
       15    0.000    0.000    7.860    0.524 test.py:695(open)
       15    0.000    0.000    7.856    0.524 test.py:655(run_wsgi_app)
       15    0.000    0.000    7.845    0.523 test.py:828(run_wsgi_app)
       15    0.000    0.000    7.844    0.523 application.py:101(__call__)
       15    0.000    0.000    7.827    0.522 sessions.py:329(__call__)
       15    0.000    0.000    7.205    0.480 course_object.py:14(__call__)
      176    0.004    0.000    6.605    0.038 __init__.py:42(instrumented_method)
       15    0.000    0.000    6.591    0.439 user_auth.py:7(__call__)
      176    0.008    0.000    6.314    0.036 __init__.py:58(get_stack)
      176    0.001    0.000    6.305    0.036 inspect.py:1063(stack)
      176    0.027    0.000    6.304    0.036 inspect.py:1036(getouterframes)
     7839    0.081    0.000    6.274    0.001 inspect.py:998(getframeinfo)
       15    0.000    0.000    5.983    0.399 application.py:27(application)
       15    0.001    0.000    5.983    0.399 application.py:81(wsgi_app)
       15    0.000    0.000    5.901    0.393 ember_backend.py:188(__call__)
       15    0.000    0.000    5.899    0.393 ember_backend.py:233(handle_request)
15714/15713    0.189    0.000    5.828    0.000 inspect.py:441(getsourcefile)
      294    0.002    0.000    5.473    0.019 cursor.py:1072(next)
      248    0.002    0.000    5.470    0.022 cursor.py:998(_refresh)
      144    0.004    0.000    5.445    0.038 cursor.py:912(__send_message)
     8367    2.133    0.000    5.342    0.001 inspect.py:473(getmodule)
      249    0.002    0.000    4.316    0.017 base.py:1131(next)
        8    0.000    0.000    3.966    0.496 test_progress.py:31(get_progress_data)
        4    0.000    0.000    3.209    0.802 test_progress.py:25(finish_item)
     7839    0.098    0.000    3.185    0.000 inspect.py:519(findsource)
        7    0.000    0.000    2.944    0.421 ember_backend.py:240(_handle_request)
        8    0.000    0.000    2.898    0.362 ember_backend.py:307(_handle_request)
        8    0.000    0.000    2.898    0.362 user_state.py:13(list)
        8    0.001    0.000    2.820    0.352 user_progress.py:28(update_progress)
       61    0.001    0.000    2.546    0.042 base.py:168(get)
        4    0.000    0.000    2.534    0.633 entity.py:253(post)
850362/849305    2.315    0.000    2.344    0.000 {hasattr}
    92/63    0.001    0.000    2.004    0.032 objects.py:22(__get__)
      127    0.001    0.000    1.915    0.015 queryset.py:65(_iter_results)
       51    0.001    0.000    1.914    0.038 queryset.py:83(_populate_cache)
       29    0.000    0.000    1.607    0.055 __init__.py:81(save)
       29    0.001    0.000    1.605    0.055 document.py:181(save)

0 个答案:

没有答案
相关问题