From cb5b475a28a9ef5ecbdfc317814464cbf1cf09c1 Mon Sep 17 00:00:00 2001 From: dam Date: Sat, 19 Aug 2023 01:48:00 +0100 Subject: Testing performance of different loop approaches. --- ttt.jai | 90 +++++++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 28 deletions(-) (limited to 'ttt.jai') diff --git a/ttt.jai b/ttt.jai index 22c6156..fe2655a 100644 --- a/ttt.jai +++ b/ttt.jai @@ -465,27 +465,22 @@ update_total_times :: (db: *Database) { // totals.data = .[]; // TODO WIP - Check what size there is for a [..] s64... + // Check what size there is for a [..] s64... print(">>%<<", db.total_times.count); // memset(totals.data, 0, db.total_times.count * size_of(s64)); // memset(db.total_times.data, 0, size_of(type_of(db.total_times))); - for xpto: 1..20 { + for xpto: 1..50 { start := current_time_monotonic(); for * total : db.total_times { < string { - builder: String_Builder; - defer reset(*builder); - for 0..6 { - print_to_builder(*builder, code, it); - } - return builder_to_string(*builder); - } - - totals: []s64 = db.total_times; - for db.tasks { - times : []s64 = it.times; - #insert #run unroll_week("totals[%1] = add(totals[%1], times[%1]);"); - } + // unroll_week :: (code: string) -> string { + // builder: String_Builder; + // defer reset(*builder); + // for 0..6 { + // print_to_builder(*builder, code, it); + // } + // return builder_to_string(*builder); + // } +// + // totals: []s64 = db.total_times; + // for db.tasks { + // times : []s64 = it.times; + // #insert #run unroll_week("totals[%1] = add(totals[%1], times[%1]);"); + // } stop := current_time_monotonic(); - average: float64 = xx to_microseconds(stop-start); + average: float64 = xx to_nanoseconds(stop-start); x_average = (average + x_count * x_average) / (x_count + 1); x_count += 1; } - print("Measured % us.\n", x_average); + print("Measured % ns/entry.\n", x_average/(cast(float64)db.tasks.count)); } // Resets the times of the provided task (and adjusts database totals). -- cgit v1.2.3