@@ -35,25 +35,21 @@ def test_timezone_function_caching_performance(self):
3535 """Test that timezone function caching improves performance."""
3636 from pythonLogs .log_utils import get_timezone_function
3737
38- # First call (not cached)
38+ # First call (not cached) - single call to prime the cache
3939 start_time = time .time ()
40- for _ in range (50 ):
41- get_timezone_function ("America/New_York" )
40+ get_timezone_function ("America/New_York" )
4241 first_call_time = time .time () - start_time
4342
44- # Clear cache and test again
45- get_timezone_function .cache_clear ()
46-
47- # Subsequent calls (should be from cache after first)
43+ # Subsequent calls (should be from cache)
4844 start_time = time .time ()
4945 for _ in range (50 ):
5046 get_timezone_function ("America/New_York" ) # Same timezone, should be cached
5147 cached_call_time = time .time () - start_time
5248
53- # Cached calls should be significantly faster
54- # Note: Since caching happens after the first call, we expect similar times
55- # but the cache prevents repeated timezone object creation
56- assert cached_call_time <= first_call_time * 1.5 # Allow some tolerance
49+ # Cached calls should be significantly faster per call
50+ # Compare average time per call
51+ cached_avg_time = cached_call_time / 50
52+ assert cached_avg_time <= first_call_time # Cached should be faster or equal
5753
5854 def test_timezone_offset_caching_performance (self ):
5955 """Test timezone offset calculation caching performance."""
0 commit comments