HTML Preparation code:
AخA
 
1
<script src='https://cdn.jsdelivr.net/pyodide/v0.26.3/full/pyodide.js'></script>
Script Preparation code:
x
 
async function globalMeasureThatScriptPrepareFunction() {
    window.globalPyodide = await loadPyodide();
    console.log(globalPyodide.runPython('import sys; sys.version'));
    await globalPyodide.loadPackage('numpy');
    await globalPyodide.runPython(`
        import numpy as np
        import random
        def bubble_sort(arr):
            n = len(arr)
            for i in range(n):
                for j in range(0, n-i-1):
                    if arr[j] > arr[j+1]:
                        arr[j], arr[j+1] = arr[j+1], arr[j]
            return arr
        def efficient_sort(arr):
            return sorted(arr)
        def generate_random_array(size, lower_bound, upper_bound):
            return [random.randint(lower_bound, upper_bound) for _ in range(size)]
        # Generate a random array
        random_array = generate_random_array(250, 1, 500000)
        print("Original array:", random_array)
    `);    
}
Tests:
  • Test #1 bubble_sorted_array

     
    window.globalPyodide.runPython(`
        bubble_sort(random_array.copy())
    `);
  • Test#2 efficient_sorted_array

     
    window.globalPyodide.runPython(`
        efficient_sort(random_array.copy())
    `);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Test #1 bubble_sorted_array
    Test#2 efficient_sorted_array

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 8 days ago)
Mozilla/5.0 (Android 15; Mobile; rv:136.0) Gecko/136.0 Firefox/136.0
Firefox Mobile 136 on Android
View result in a separate tab
Test name Executions per second
Test #1 bubble_sorted_array 148.3 Ops/sec
Test#2 efficient_sorted_array 1150.1 Ops/sec