Skip to content

Commit 2020a7a

Browse files
authored
V5.0.1 (#15)
Co-authored-by: ddc <ddc@users.noreply.github.com>
1 parent 3ca50a7 commit 2020a7a

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/performance/test_performance.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ def test_timezone_function_caching(self):
122122
assert elapsed_time < 0.5
123123
assert len(loggers) == 20
124124

125+
@pytest.mark.skipif(
126+
sys.platform == "win32",
127+
reason="Windows timing precision issues - see test_performance_windows.py",
128+
)
125129
def test_enum_vs_string_performance(self):
126130
"""Test that enum usage doesn't significantly impact performance."""
127131
# Test with string values

tests/performance/test_performance_windows.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,32 @@ def test_stress_test_factory_pattern_windows(self):
121121
# Verify registry has cached logger
122122
assert "stress_cached_win" in get_registered_loggers()
123123

124+
@pytest.mark.skipif(sys.platform != "win32", reason="Windows-specific tests")
125+
def test_enum_vs_string_performance_windows(self):
126+
"""Test that enum usage doesn't significantly impact performance on Windows."""
127+
# Test with string values
128+
start_time = time.perf_counter()
129+
for i in range(25):
130+
create_logger("basic", name=f"string_test_{i}_win", level="INFO")
131+
string_time = time.perf_counter() - start_time
132+
133+
# Test with enum values
134+
start_time = time.perf_counter()
135+
for i in range(25):
136+
create_logger(LoggerType.BASIC, name=f"enum_test_{i}_win", level=LogLevel.INFO)
137+
enum_time = time.perf_counter() - start_time
138+
139+
# Handle Windows timing precision issues
140+
# If string_time is too small to measure accurately
141+
min_threshold = 0.001 # 1ms minimum threshold
142+
if string_time < min_threshold:
143+
# If timing is too precise, just ensure enum operations complete reasonably fast
144+
assert enum_time < 0.1 # Should complete within 100ms
145+
else:
146+
# Normal case: enum performance should be comparable to strings
147+
# Allow 60% tolerance for enum conversion overhead
148+
assert enum_time <= string_time * 1.6
149+
124150
@pytest.mark.skipif(sys.platform != "win32", reason="Windows-specific tests")
125151
def test_windows_file_locking_resilience_performance(self):
126152
"""Test performance with Windows file locking scenarios."""

0 commit comments

Comments
 (0)