Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Python Enum vs string compare v2
(version: 1)
Comparing performance of:
Test #1 Enum vs String compare
Created:
one year ago
by:
Guest
Go to the latest result
HTML Preparation code:
<script src='https://cdn.jsdelivr.net/pyodide/v0.26.3/full/pyodide.js'></script>
Script Preparation code:
async function globalMeasureThatScriptPrepareFunction() { window.globalPyodide = await loadPyodide(); console.log(globalPyodide.runPython('import sys; sys.version')); await globalPyodide.runPython(` from enum import Enum, auto class TestEnum(Enum): a = auto() b = auto() `); }
Tests:
Test #1 Enum
window.globalPyodide.runPython(` c = 0 for i in range(0, 100000): v = TestEnum.a if i % 2 == 0 else TestEnum.b if v is TestEnum.a: c = c + 1 `);
String compare
window.globalPyodide.runPython(` c = 0 for i in range(0, 100000): v = "connected" if i % 2 == 0 else "connecting" if v == "connected": c = c + 1 `);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Test #1 Enum
String compare
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
11 days ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 Edg/148.0.0.0
Browser/OS:
Chrome 148 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
String compare
15/s
Test #1 Enum
11/s
View exact numbers
Test name
Executions per second
✓
String compare
15 Ops/sec
Test #1 Enum
11 Ops/sec
Related benchmarks
int vs string comparison
Compare string equals performance
Compare string equals performance without case diffs
Compare string equals performance without case diffs!
string vs numeric enum values compare
Python Enum vs string compare
Comments
Confirm delete:
Do you really want to delete benchmark?