Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
251 changes: 251 additions & 0 deletions benchmarks/sql/LINQ_TO_TABLE.md

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions benchmarks/sql/_common.das
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@ def public fixture_json(n : int) : JsonValue? {
return JV([for (c in fixture_array(n)); JV(c)])
}

// Table fold lane (m7): same Car schema keyed by id in a table<int; Car>. Same deterministic row
// generator as fixture_array so the table lane is directly comparable to the array (m3f) lane; table
// slot order is unspecified, so m7 expectations stay order-insensitive (aggregates / counts).
def public fixture_table(n : int) : table<int; Car> {
var t <- {
for (i in range(n));
i + 1 => Car(
id = i + 1,
name = "Car{i}",
price = (i * 37) % 1000,
brand = i % BRAND_COUNT,
year = 2010 + (i * 7) % 16,
dealer_id = (i % DEALER_COUNT) + 1
)
}
return <- t
}

def public fixture_dealers_array() : array<Dealer> {
var arr : array<Dealer>
arr |> resize(DEALER_COUNT)
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/sql/_update_results.das
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ struct Config {
help : bool
}

let LANES = ["m1", "m3f", "m4", "m5f", "m6f"]
let HEADERS = ["SQL (m1)", "Array (m3f)", "Decs (m4)", "XML fold (m5f)", "JSON fold (m6f)"]
let LANES = ["m1", "m3f", "m4", "m5f", "m6f", "m7"]
let HEADERS = ["SQL (m1)", "Array (m3f)", "Decs (m4)", "XML fold (m5f)", "JSON fold (m6f)", "Table fold (m7)"]
let BEGIN_MARKER = "<!-- BENCH:TABLES BEGIN -->"
let END_MARKER = "<!-- BENCH:TABLES END -->"

Expand Down
27 changes: 27 additions & 0 deletions benchmarks/sql/array.das
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,33 @@ def to_array_filter_m3f(b : B?) {
}
}

[benchmark]
def to_table_m3f(b : B?) {
// fused insert-loop sink: the chain lands straight in the result table
b |> run("to_table", N) {
var tab <- _fold(each(g_arr) |> _select((_.id => _.price)) |> to_table())
b |> accept(length(tab))
if (empty(tab)) {
b->failNow()
}
delete tab
}
}

[benchmark]
def to_table_staged_m3f(b : B?) {
// staged baseline: materialize the kv tuples to an array, then convert
b |> run("to_table_staged", N) {
var rows <- _fold(each(g_arr) |> _select((_.id => _.price)) |> to_array())
var tab <- to_table_move(rows)
b |> accept(length(tab))
if (empty(tab)) {
b->failNow()
}
delete tab
}
}

[benchmark]
def where_join_count_m3f(b : B?) {
b |> run("where_join_count", N) {
Expand Down
27 changes: 27 additions & 0 deletions benchmarks/sql/decs.das
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,33 @@ def to_array_filter_m4(b : B?) {
}
}

[benchmark]
def to_table_m4(b : B?) {
// fused insert-loop sink: the chain lands straight in the result table
b |> run("to_table", N) {
var tab <- _fold(from_decs_template(type<DecsCar>) |> _select((_.id => _.price)) |> to_table())
b |> accept(length(tab))
if (empty(tab)) {
b->failNow()
}
delete tab
}
}

[benchmark]
def to_table_staged_m4(b : B?) {
// staged baseline: materialize the kv tuples to an array, then convert
b |> run("to_table_staged", N) {
var rows <- _fold(from_decs_template(type<DecsCar>) |> _select((_.id => _.price)) |> to_array())
var tab <- to_table_move(rows)
b |> accept(length(tab))
if (empty(tab)) {
b->failNow()
}
delete tab
}
}

[benchmark]
def where_join_count_m4(b : B?) {
b |> run("where_join_count", N) {
Expand Down
27 changes: 27 additions & 0 deletions benchmarks/sql/json.das
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,33 @@ def to_array_filter_m6f(b : B?) {
}
}

[benchmark]
def to_table_m6f(b : B?) {
// fused insert-loop sink: the chain lands straight in the result table
b |> run("to_table", N) {
var tab <- _fold(unsafe(from_json(g_jv, type<Car>)) |> _select((_.id => _.price)) |> to_table())
b |> accept(length(tab))
if (empty(tab)) {
b->failNow()
}
delete tab
}
}

[benchmark]
def to_table_staged_m6f(b : B?) {
// staged baseline: materialize the kv tuples to an array, then convert
b |> run("to_table_staged", N) {
var rows <- _fold(unsafe(from_json(g_jv, type<Car>)) |> _select((_.id => _.price)) |> to_array())
var tab <- to_table_move(rows)
b |> accept(length(tab))
if (empty(tab)) {
b->failNow()
}
delete tab
}
}

[benchmark]
def where_join_count_m6f(b : B?) {
b |> run("where_join_count", N) {
Expand Down
348 changes: 186 additions & 162 deletions benchmarks/sql/results.md

Large diffs are not rendered by default.

Loading
Loading