60
60
61
61
import pymunk
62
62
63
- try :
64
- import pygame
65
-
66
- import pymunk .pygame_util
67
-
68
- pymunk .pygame_util .positive_y_is_up = True
69
- except :
70
- pass
71
-
72
63
73
64
class Benchmark :
74
65
steps = 500
@@ -176,7 +167,7 @@ def update(self, dt):
176
167
177
168
178
169
class AddPair (Benchmark ):
179
- steps = 1000
170
+ steps = 3000
180
171
default_size = 2000
181
172
size_start = 100
182
173
size_end = 2500
@@ -614,6 +605,12 @@ def run(bench_cls, size, interactive):
614
605
sim_start_time = timeit .default_timer ()
615
606
616
607
if interactive :
608
+ import pygame
609
+
610
+ import pymunk .pygame_util
611
+
612
+ pymunk .pygame_util .positive_y_is_up = True
613
+
617
614
clock = pygame .time .Clock ()
618
615
screen = pygame .display .set_mode ((600 , 600 ))
619
616
draw_options = pymunk .pygame_util .DrawOptions (screen )
@@ -671,7 +668,7 @@ def run(bench_cls, size, interactive):
671
668
f"step { steps } fps { clock .get_fps ():.2f} total { timeit .default_timer ()- sim_start_time :.2f} s"
672
669
)
673
670
674
- sim .update (1 / fps )
671
+ sim .update (1 / fps / 50 )
675
672
steps += 1
676
673
677
674
if not interactive and False : # temp disabled until end state is nice to look at.
@@ -710,7 +707,8 @@ def run(bench_cls, size, interactive):
710
707
"-s" ,
711
708
"--size" ,
712
709
type = int ,
713
- help = "Size of simulation (e.g. number of items). Set to -1 to iterate the sizes" ,
710
+ help = """Size of simulation (e.g. number of items). If not set uses a default size.
711
+ Set to -1 to iterate the sizes""" ,
714
712
)
715
713
parser .add_argument (
716
714
"-i" ,
@@ -723,7 +721,7 @@ def run(bench_cls, size, interactive):
723
721
724
722
csv_output = io .StringIO ()
725
723
writer = csv .DictWriter (
726
- csv_output , fieldnames = ["benchmark" , "size" , "init_time" , "run_time" ]
724
+ csv_output , fieldnames = ["version" , " benchmark" , "size" , "init_time" , "run_time" ]
727
725
)
728
726
writer .writeheader ()
729
727
for name in args .benchmarks :
@@ -750,6 +748,7 @@ def run(bench_cls, size, interactive):
750
748
751
749
res = run (bench_cls , size , args .interactive )
752
750
print (res )
751
+ res ["version" ] = pymunk .version
753
752
writer .writerow (res )
754
753
print ("DONE!" )
755
754
print ("Full Result:" )
0 commit comments