{
    "schema": "phplyr-backends/1",
    "generated_at": "2026-10-18T22:55:56Z",
    "method": {
        "statistic": "best",
        "repeats": 3,
        "timing": "pipeline through collect(); data preloaded and not timed",
        "verification": "rows canonicalised (floats to 9 significant digits, sorted) and hashed, then compared with the reference backend",
        "reference": "DataFrame",
        "polars_threads": 2,
        "threads_note": "polars_threads applies to PolarsTable only; DataFrame and SqlTable(SQLite) run single-threaded",
        "machine": {
            "os": "Darwin 27.0.0 arm64",
            "cpu": "Apple M5 Ultra",
            "cores": 30,
            "memory_gb": 96
        },
        "php": "8.5.10",
        "versions": {
            "phplyr": "ed999d8",
            "phibble": "b12503e",
            "phpolars": {
                "sha": null,
                "extension": "0.1.0",
                "polars": "0.55.2",
                "profile": "release"
            },
            "sqlite": "3.53.4"
        },
        "data": {
            "script": "bench/backends.php",
            "seed": 7,
            "tables": {
                "sales": "id, store (100 values), product (1,000), day (1-365), units (about 2% NA, 5% zero), price",
                "stores": "store, region (5 values)"
            },
            "note": "no date or datetime columns; datetime columns add about 0.2 s per 1M rows to PolarsTable collect()"
        }
    },
    "pipelines": [
        {
            "id": "A",
            "title": "filter, join, grouped summary, ranked window",
            "code": "fn (Table $s, Table $st) => $s\n    |> filter(col('units')->gt(0))\n    |> left_join($st, by: 'store')\n    |> group_by('region', 'product')\n    |> summarise(n: n(), revenue: sum(col('units')->mul(col('price'))), avg_price: mean('price'))\n    |> group_by('region')\n    |> mutate(rank: min_rank(desc('revenue')))\n    |> filter(col('rank')->le(10))\n    |> arrange('region', 'rank')"
        },
        {
            "id": "B",
            "title": "per-group windows over every row",
            "code": "fn (Table $s, Table $st) => $s\n    |> group_by('store')\n    |> mutate(prev: lag('units', order_by: 'day'), running: cumsum('units'), share: col('units')->div(sum('units', na_rm: true)))"
        },
        {
            "id": "C",
            "title": "as A, with a PHP closure in filter()",
            "code": "fn (Table $s, Table $st) => $s\n    |> filter(fn ($r) => $r->units > 0)\n    |> left_join($st, by: 'store')\n    |> group_by('region', 'product')\n    |> summarise(n: n(), revenue: sum(col('units')->mul(col('price'))), avg_price: mean('price'))\n    |> group_by('region')\n    |> mutate(rank: min_rank(desc('revenue')))\n    |> filter(col('rank')->le(10))\n    |> arrange('region', 'rank')"
        }
    ],
    "results": [
        {
            "pipeline": "A",
            "backend": "DataFrame",
            "rows_in": 100000,
            "rows_out": 50,
            "seconds": 0.0888,
            "seconds_all": [
                0.0937,
                0.0888,
                0.089
            ],
            "fallbacks": null,
            "matches_frame": true,
            "checksums": {
                "rows": 50,
                "sums": {
                    "product": 22974,
                    "n": 1403,
                    "revenue": 943659.8500000001,
                    "avg_price": 2847.4855236300036,
                    "rank": 275
                }
            },
            "error": null
        },
        {
            "pipeline": "A",
            "backend": "PolarsTable",
            "rows_in": 100000,
            "rows_out": 50,
            "seconds": 0.0059,
            "seconds_all": [
                0.0102,
                0.0061,
                0.0059
            ],
            "fallbacks": 0,
            "matches_frame": true,
            "checksums": null,
            "error": null
        },
        {
            "pipeline": "A",
            "backend": "SqlTable(SQLite)",
            "rows_in": 100000,
            "rows_out": 50,
            "seconds": 0.0427,
            "seconds_all": [
                0.0445,
                0.0437,
                0.0427
            ],
            "fallbacks": null,
            "matches_frame": true,
            "checksums": null,
            "error": null
        },
        {
            "pipeline": "B",
            "backend": "DataFrame",
            "rows_in": 100000,
            "rows_out": 100000,
            "seconds": 0.0948,
            "seconds_all": [
                0.0948,
                0.0952,
                0.0967
            ],
            "fallbacks": null,
            "matches_frame": true,
            "checksums": {
                "rows": 100000,
                "sums": {
                    "id": 5000050000,
                    "store": 5047455,
                    "product": 49968472,
                    "day": 18279177,
                    "units": 978103,
                    "price": 5064521.249999999,
                    "prev": 977138,
                    "running": 1844343,
                    "share": 100.00000000000504
                }
            },
            "error": null
        },
        {
            "pipeline": "B",
            "backend": "PolarsTable",
            "rows_in": 100000,
            "rows_out": 100000,
            "seconds": 0.0425,
            "seconds_all": [
                0.0425,
                0.043,
                0.0431
            ],
            "fallbacks": 0,
            "matches_frame": true,
            "checksums": null,
            "error": null
        },
        {
            "pipeline": "B",
            "backend": "SqlTable(SQLite)",
            "rows_in": 100000,
            "rows_out": 100000,
            "seconds": 0.3109,
            "seconds_all": [
                0.3109,
                0.3167,
                0.3155
            ],
            "fallbacks": null,
            "matches_frame": true,
            "checksums": null,
            "error": null
        },
        {
            "pipeline": "C",
            "backend": "DataFrame",
            "rows_in": 100000,
            "rows_out": 50,
            "seconds": 0.116,
            "seconds_all": [
                0.1168,
                0.116,
                0.1191
            ],
            "fallbacks": null,
            "matches_frame": true,
            "checksums": {
                "rows": 50,
                "sums": {
                    "product": 22974,
                    "n": 1403,
                    "revenue": 943659.8500000001,
                    "avg_price": 2847.4855236300036,
                    "rank": 275
                }
            },
            "error": null
        },
        {
            "pipeline": "C",
            "backend": "PolarsTable",
            "rows_in": 100000,
            "rows_out": 50,
            "seconds": 0.0783,
            "seconds_all": [
                0.079,
                0.0824,
                0.0783
            ],
            "fallbacks": 1,
            "matches_frame": true,
            "checksums": null,
            "error": null
        },
        {
            "pipeline": "C",
            "backend": "SqlTable(SQLite)",
            "rows_in": 100000,
            "rows_out": 50,
            "seconds": 0.1971,
            "seconds_all": [
                0.2024,
                0.1971,
                0.2047
            ],
            "fallbacks": null,
            "matches_frame": true,
            "checksums": null,
            "error": null
        },
        {
            "pipeline": "A",
            "backend": "DataFrame",
            "rows_in": 1000000,
            "rows_out": 50,
            "seconds": 0.7509,
            "seconds_all": [
                0.7701,
                0.7509,
                0.7541
            ],
            "fallbacks": null,
            "matches_frame": true,
            "checksums": {
                "rows": 50,
                "sums": {
                    "product": 24103,
                    "n": 10619,
                    "revenue": 6274392.53,
                    "avg_price": 2654.3459970933004,
                    "rank": 275
                }
            },
            "error": null
        },
        {
            "pipeline": "A",
            "backend": "PolarsTable",
            "rows_in": 1000000,
            "rows_out": 50,
            "seconds": 0.0506,
            "seconds_all": [
                0.0702,
                0.051,
                0.0506
            ],
            "fallbacks": 0,
            "matches_frame": true,
            "checksums": null,
            "error": null
        },
        {
            "pipeline": "A",
            "backend": "SqlTable(SQLite)",
            "rows_in": 1000000,
            "rows_out": 50,
            "seconds": 0.4337,
            "seconds_all": [
                0.4402,
                0.4337,
                0.4456
            ],
            "fallbacks": null,
            "matches_frame": true,
            "checksums": null,
            "error": null
        },
        {
            "pipeline": "B",
            "backend": "DataFrame",
            "rows_in": 1000000,
            "rows_out": 1000000,
            "seconds": 1.2458,
            "seconds_all": [
                1.2517,
                1.2458,
                1.2479
            ],
            "fallbacks": null,
            "matches_frame": true,
            "checksums": {
                "rows": 1000000,
                "sums": {
                    "id": 500000500000,
                    "store": 50471922,
                    "product": 500634673,
                    "day": 183070333,
                    "units": 9765654,
                    "price": 50497530.880000904,
                    "prev": 9764642,
                    "running": 1844343,
                    "share": 99.9999999999831
                }
            },
            "error": null
        },
        {
            "pipeline": "B",
            "backend": "PolarsTable",
            "rows_in": 1000000,
            "rows_out": 1000000,
            "seconds": 0.4153,
            "seconds_all": [
                0.4208,
                0.4153,
                0.4208
            ],
            "fallbacks": 0,
            "matches_frame": true,
            "checksums": null,
            "error": null
        },
        {
            "pipeline": "B",
            "backend": "SqlTable(SQLite)",
            "rows_in": 1000000,
            "rows_out": 1000000,
            "seconds": 3.3322,
            "seconds_all": [
                3.3634,
                3.3322,
                3.3512
            ],
            "fallbacks": null,
            "matches_frame": true,
            "checksums": null,
            "error": null
        },
        {
            "pipeline": "C",
            "backend": "DataFrame",
            "rows_in": 1000000,
            "rows_out": 50,
            "seconds": 1.1286,
            "seconds_all": [
                1.2708,
                1.1286,
                1.239
            ],
            "fallbacks": null,
            "matches_frame": true,
            "checksums": {
                "rows": 50,
                "sums": {
                    "product": 24103,
                    "n": 10619,
                    "revenue": 6274392.53,
                    "avg_price": 2654.3459970933004,
                    "rank": 275
                }
            },
            "error": null
        },
        {
            "pipeline": "C",
            "backend": "PolarsTable",
            "rows_in": 1000000,
            "rows_out": 50,
            "seconds": 0.8742,
            "seconds_all": [
                0.8763,
                0.9779,
                0.8742
            ],
            "fallbacks": 1,
            "matches_frame": true,
            "checksums": null,
            "error": null
        },
        {
            "pipeline": "C",
            "backend": "SqlTable(SQLite)",
            "rows_in": 1000000,
            "rows_out": 50,
            "seconds": 2.0136,
            "seconds_all": [
                2.1053,
                2.0136,
                2.152
            ],
            "fallbacks": null,
            "matches_frame": true,
            "checksums": null,
            "error": null
        }
    ]
}
