Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Python Enum vs string compare
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:143.0) Gecko/20100101 Firefox/143.0
Browser:
Firefox 143
Operating system:
Linux
Device Platform:
Desktop
Date tested:
3 months ago
Test name
Executions per second
Test #1 Enum
41.6 Ops/sec
String compare
56.0 Ops/sec
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() a = "connected" b = "disconnected" `); }
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 "disconnected" if v == "connected": c = c + 1 `);