@@ -1154,6 +1154,7 @@ def test_bulk_update(self):
11541154 PerfCompare ,
11551155 SingleEnumPerf ,
11561156 SingleFieldPerf ,
1157+ SingleNoCoercePerf
11571158 )
11581159 from enum_properties import EnumProperties , s
11591160
@@ -2674,12 +2675,19 @@ def test_single_field_perf_diff(self):
26742675 SingleFieldPerf .objects .create (small_pos_int = 0 )
26752676 choice_stop = perf_counter ()
26762677
2678+ no_coerce_start = perf_counter ()
2679+ for idx in range (0 , self .COUNT ):
2680+ SingleNoCoercePerf .objects .create (small_pos_int = 0 )
2681+ no_coerce_end = perf_counter ()
2682+
26772683 enum_time = enum_stop - enum_start
26782684 choice_time = choice_stop - choice_start
2685+ no_coerce_time = no_coerce_end - no_coerce_start
26792686
2687+ print (f'{ enum_time } { choice_time } { no_coerce_time } ' )
26802688 # Enum tends to be about ~12% slower
26812689 self .assertTrue ((enum_time / choice_time ) < 1.5 )
2682- # print(f'{enum_time} { choice_time}' )
2690+ self . assertTrue (( no_coerce_time / choice_time ) < 1.1 )
26832691
26842692 enum_start = perf_counter ()
26852693 for _ in SingleEnumPerf .objects .all ():
@@ -2691,13 +2699,22 @@ def test_single_field_perf_diff(self):
26912699 continue
26922700 choice_stop = perf_counter ()
26932701
2702+ no_coerce_start = perf_counter ()
2703+ for _ in SingleNoCoercePerf .objects .all ():
2704+ continue
2705+ no_coerce_end = perf_counter ()
2706+
26942707 enum_time = enum_stop - enum_start
26952708 choice_time = choice_stop - choice_start
2709+ no_coerce_time = no_coerce_end - no_coerce_start
26962710
2697- # print(f'{enum_time} {choice_time}')
2711+ print (f'{ enum_time } { choice_time } { no_coerce_time } ' )
26982712 # tends to be about 1.8x slower
26992713 self .assertTrue ((enum_time / choice_time ) < 2.5 )
27002714
2715+ # todo how to tighten this? why so much slower still?
2716+ self .assertTrue ((no_coerce_time / choice_time ) < 1.7 )
2717+
27012718
27022719 class ExampleTests (TestCase ): # pragma: no cover - why is this necessary?
27032720
0 commit comments