aboutsummaryrefslogtreecommitdiff
path: root/ttt.jai
diff options
context:
space:
mode:
authordam <dam@gudinoff>2023-08-19 01:48:00 +0100
committerdam <dam@gudinoff>2023-08-19 01:48:00 +0100
commitcb5b475a28a9ef5ecbdfc317814464cbf1cf09c1 (patch)
treeb0b0168fd7dcc28650d549cd59e03d0008c14bdd /ttt.jai
parent709879ee56d31fe543a0ad882713bd4e3d17d2d2 (diff)
downloadtask-time-tracker-cb5b475a28a9ef5ecbdfc317814464cbf1cf09c1.tar.zst
task-time-tracker-cb5b475a28a9ef5ecbdfc317814464cbf1cf09c1.zip
Testing performance of different loop approaches.
Diffstat (limited to 'ttt.jai')
-rw-r--r--ttt.jai90
1 files changed, 62 insertions, 28 deletions
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 { <<total = 0; }
- // 24ms
- // for db.tasks {
- // times : []s64 = it.times;
- // for *total: db.total_times {
- // <<total = add(<<total, times[it_index]);
- // }
- // }
-
- // 10ms
+ // ns/entry
+ // LLVM 14.5
+ // X64 132.4
+ //
// totals: []s64 = db.total_times;
// for db.tasks {
// times : []s64 = it.times;
@@ -498,7 +493,46 @@ update_total_times :: (db: *Database) {
// totals[6] = add(totals[6], times[6]);
// }
- // 21ms
+
+ // ns/entry
+ // LLVM 11.2
+ // X64 119.9
+ //
+ for db.tasks {
+ for *total: db.total_times {
+ <<total = add(<<total, it.times[it_index]);
+ }
+ }
+
+
+ // ns/entry
+ // LLVM 11.5
+ // X64 126.6
+ //
+ // for db.tasks {
+ // times : []s64 = it.times;
+ // for *total: db.total_times {
+ // <<total = add(<<total, times[it_index]);
+ // }
+ // }
+
+
+ // ns/entry
+ // LLVM 11.8
+ // X64 134.4
+ //
+ // totals: []s64 = db.total_times;
+ // for db.tasks {
+ // times : []s64 = it.times;
+ // for 0..totals.count-1 {
+ // totals[it] = add(totals[it], times[it]);
+ // }
+ // }
+
+ // ns/entry
+ // LLVM 11.6
+ // X64 132.3
+ //
// for db.tasks {
// times : []s64 = it.times;
// for 0..db.total_times.count-1 {
@@ -506,30 +540,30 @@ update_total_times :: (db: *Database) {
// }
// }
- 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]);");
- }
+ // 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).