Results 1 to 5 of 5
  1. #1
    Moderator Monster's Avatar
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    13,737

    [Benchmark] What is faster Property Sensor or Python Controller?

    Hi,

    This is a question that was discussed recently.

    The arguments for pro and contra seems to be very valid.
    But as we all know reality does not care our arguments.



    So I run some benchmark tests to check what is faster:
    Evaluating a property sensor
    vs.
    Evaluating an Always sensor and executing a Python controller (in Script mode and in Module mode)
    All three runs perform the same logic:

    - Checking if a property has a specific value (-1)
    - If not activate a property controller to change the property

    In the test the value will not be matched that the actuator does always run (worst case).

    Here are my results 2.49b:

    Winner is:
    Property sensor = 100% (48fps)

    followed by
    Python controller in Module mode ~ 25% (11fps)
    Python controller in Script mode ~ 15 % (7fps)

    The plot shows that the the performance with the property sensor is not very stable, but still better than the other solution.

    I needed 2500 cubes to reduce the property sensor solution below 60fps to 45 fps. This is system dependent. I think if you run it you will need more are less test objects.

    Here are my results 2.57b:
    The winner is the Property sensor again.

    But the fps plot looks much more instable here with 13fps - 35 fps.

    Python controller Module mode - stable with 10 FPS (a bit slower than 2.49)
    Python controller Script mode - stable with 7 FPS

    Remarks:
    The test runs in worst case. This means the Property sensor triggers all the time. In other cases the performance of this solution will be much better as the controller will not be processed

    Even if the property solution is better there might be situations when an Always sensor with a Python script is better. This is the case is you need to execute the controller anyway but this is due to the fact that the always sensor is faster than the property sensor [have I benchmarked that? Maybe you can do that for me )

    I hope you found this interesting

    Monster

    PS:
    The template for own tests:
    Benchmark Template 1.0
    Attached Files Attached Files
    Last edited by Monster; 14-Jul-11 at 10:19.



  2. #2
    Moderator Monster's Avatar
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    13,737
    My results:
    2.57b
    Code:
    Blender Game Engine Started
    BENCHMARK 1.0
    =============
    template by Monster
     
    profiling: TestPropSensor
    adding test objects...
    added 1000 test objects
    added 2000 test objects
    test with 2500 objects
    FPS 0............................................................60
    1000000  >                                                            <#
    11  >         #                                                  <
    13  >           #                                                <
    14  >            #                                               <
    15  >             #                                              <
    16  >              #                                             <
    17  >               #                                            <
    19  >                 #                                          <
    22  >                    #                                       <
    25  >                       #                                    <
    28  >                          #                                 <
    30  >                            #                               <
    32  >                              #                             <
    32  >                              #                             <
    35  >                                 #                          <
    36  >                                  #                         <
    40  >                                      #                     <
    46  >                                            #               <
    45  >                                           #                <
    41  >                                       #                    <
    37  >                                   #                        <
    32  >                              #                             <
    28  >                          #                                 <
    24  >                      #                                     <
    21  >                   #                                        <
    19  >                 #                                          <
    18  >                #                                           <
    17  >               #                                            <
    16  >              #                                             <
    15  >             #                                              <
    15  >             #                                              <
    17  >               #                                            <
    18  >                #                                           <
    20  >                  #                                         <
    23  >                     #                                      <
    25  >                       #                                    <
    28  >                          #                                 <
    30  >                            #                               <
    30  >                            #                               <
    30  >                            #                               <
    30  >                            #                               <
    30  >                            #                               <
    30  >                            #                               <
    30  >                            #                               <
    30  >                            #                               <
    30  >                            #                               <
    Blender Game Engine Finished
    Blender Game Engine Started
    BENCHMARK 1.0
    =============
    template by Monster
     
    profiling: TestPythonModule
    adding test objects...
    added 1000 test objects
    added 2000 test objects
    test with 2500 objects
    FPS 0............................................................60
    1000000  >                                                            <#
    07  >     #                                                      <
    09  >       #                                                    <
    09  >       #                                                    <
    09  >       #                                                    <
    09  >       #                                                    <
    09  >       #                                                    <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    09  >       #                                                    <
    09  >       #                                                    <
    09  >       #                                                    <
    09  >       #                                                    <
    09  >       #                                                    <
    09  >       #                                                    <
    09  >       #                                                    <
    09  >       #                                                    <
    09  >       #                                                    <
    09  >       #                                                    <
    09  >       #                                                    <
    09  >       #                                                    <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    10  >        #                                                   <
    Blender Game Engine Finished
    Blender Game Engine Started
    BENCHMARK 1.0
    =============
    template by Monster
     
    profiling: TestPythonScript
    adding test objects...
    added 1000 test objects
    added 2000 test objects
    test with 2500 objects
    FPS 0............................................................60
    1000000  >                                                            <#
    07  >     #                                                      <
    07  >     #                                                      <
    07  >     #                                                      <
    07  >     #                                                      <
    06  >    #                                                       <
    06  >    #                                                       <
    06  >    #                                                       <
    07  >     #                                                      <
    07  >     #                                                      <
    07  >     #                                                      <
    07  >     #                                                      <
    07  >     #                                                      <
    07  >     #                                                      <
    07  >     #                                                      <
    07  >     #                                                      <
    07  >     #                                                      <
    07  >     #                                                      <
    07  >     #                                                      <
    07  >     #                                                      <
    07  >     #                                                      <
    07  >     #                                                      <
    07  >     #                                                      <
    07  >     #                                                      <
    Blender Game Engine Finished



  3. #3
    Member Rubbernuke's Avatar
    Join Date
    Aug 2010
    Location
    Peyrat Le Chateau, France
    Posts
    1,372
    Interesting, for me both the Python controller (module mode) and property sensor are solid 59fps, but the script mode only does 10fps.

    What is module mode exactly? It seems much faster than running Script mode.



  4. #4
    @Monster - I'm getting 5 FPS on the Property Sensor scene, and 4.8 on the Python Module scene. Seems like they're the same.
    I then changed your 'Python Module scene' - instead of activating a controller, I simply added one to the property. I now get 7-7.2 FPS, which is a marked improvement.

    By looping through the objects and doing their code for them, I was able to get around 8 FPS.

    However, as far as I can see, the results are skewed, as the test has physics-enabled objects - without any printing or Python executing, the Physics load is around 48% on my computer. The test should not be biased toward physics. This is a very good test, though.



  5. #5
    Moderator Monster's Avatar
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    13,737
    In general such benchmark tests hit the performance limit of your system. As this system is hard and software dependent you need to adjust the test to get noticable results. All you need to change is the number of test objects for all test cases. This can be done by setting a property at the object Tester which is shared through all scenes.

    @Rubbernuke:
    If you hit 59-60 the test hits BGE's frame limit.
    Increase the number of test objects until you get around 40-50 fps in your best performed test case. It does not need to be exact, but it makes the results comparable.

    @SolarLune:
    It looks like the rates are to low for a good comparization. In that case decrease the number of test objects until you get around 40-50 fps in your best performed test case.

    @Rubbernuke:
    To answer your question:
    The module mode is like:
    Code:
    import GameLogic
    import MyModule
    MyModule.myFunction( GameLogic.getCurrentController() )
    when you enter
    MyModule.myFunction

    As normal modules your module stays in memory rather then reread at each controllers execution.

    The module mode was expected to be slightly better in performance than script mode.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •