Skip to content

Commit d4cd941

Browse files
committed
feat: Add matrix multiplication benchmark and implement core stdlib functions for list, string, and time operations.
1 parent 775b1fb commit d4cd941

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

benchmarks/macro/matrix_mul.prox

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
func create_matrix(rows, cols) {
3+
print("Creating matrix " + to_string(rows) + "x" + to_string(cols));
34
let m = [];
45
for (let i = 0; i < rows; i = i + 1) {
56
let row = [];
@@ -8,6 +9,7 @@ func create_matrix(rows, cols) {
89
}
910
list_push(m, row);
1011
}
12+
print("Matrix created with " + to_string(len(m)) + " rows");
1113
return m;
1214
}
1315

@@ -51,7 +53,13 @@ func main() {
5153
let elapsed = clock() - start;
5254

5355
print("Time: " + to_string(elapsed));
54-
print("C[0][0]: " + to_string(c[0][0]));
56+
if (c == null) {
57+
print("C is null");
58+
} else {
59+
print("Rows: " + to_string(len(c)));
60+
if (len(c) > 0) print("Cols: " + to_string(len(c[0])));
61+
print("C[0][0]: " + to_string(c[0][0]));
62+
}
5563
}
5664

5765
main();

src/stdlib/stdlib_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ extern Value native_clock(int argCount, Value* args);
3333
static Value native_len(int argCount, Value* args) {
3434
if (argCount < 1) return NUMBER_VAL(0);
3535
if (IS_STRING(args[0])) return NUMBER_VAL((double)AS_STRING(args[0])->length);
36-
// TODO: List/Map support
36+
if (IS_LIST(args[0])) return NUMBER_VAL((double)AS_LIST(args[0])->count);
37+
if (IS_MAP(args[0])) return NUMBER_VAL((double)AS_MAP(args[0])->count);
3738
return NUMBER_VAL(0);
3839
}
3940

0 commit comments

Comments
 (0)