Skip to content

Commit

Permalink
Added buildTimeMs to tilings
Browse files Browse the repository at this point in the history
  • Loading branch information
HHogg committed Sep 11, 2024
1 parent 9b2cf8f commit 6d82406
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
5 changes: 4 additions & 1 deletion workspaces/tilings/src-rust/tiling/src/build/context.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use chrono::TimeDelta;
use serde::Serialize;
use typeshare::typeshare;

Expand All @@ -20,6 +21,7 @@ impl Context {
notation: &Notation,
plane: &Plane,
result: &Result<(), TilingError>,
duration: TimeDelta,
) {
self.count_total_tilings += 1;

Expand All @@ -35,7 +37,8 @@ impl Context {
super::Result::default()
.with_notation(notation.to_string())
.with_hash(plane.classifier.get_unique_key())
.with_transform_index(notation.transforms.index),
.with_transform_index(notation.transforms.index)
.with_build_time_ms(duration.num_milliseconds() as i32),
);
}
_ => {}
Expand Down
11 changes: 9 additions & 2 deletions workspaces/tilings/src-rust/tiling/src/build/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ pub struct Result {
pub uniform: i32,
#[typeshare(serialized_as = "string")]
pub timestamp: NaiveDateTime,
pub build_time_ms: i32,
}

impl Result {
pub fn with_notation(mut self, notation: String) -> Self {
self.notation = notation.clone();
pub fn with_build_time_ms(mut self, build_time_ms: i32) -> Self {
self.build_time_ms = build_time_ms;
self
}

Expand All @@ -25,6 +26,11 @@ impl Result {
self
}

pub fn with_notation(mut self, notation: String) -> Self {
self.notation = notation.clone();
self
}

pub fn with_transform_index(mut self, transform_index: i32) -> Self {
self.transform_index = transform_index;
self
Expand All @@ -39,6 +45,7 @@ impl Default for Result {
transform_index: 0,
uniform: 0,
timestamp: Utc::now().naive_utc(),
build_time_ms: 0,
}
}
}
8 changes: 7 additions & 1 deletion workspaces/tilings/src-rust/tiling/src/tiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#[cfg(test)]
mod tests;

use chrono::{TimeDelta, Utc};
use serde::Serialize;
use serde_with::{serde_as, DisplayFromStr};
use typeshare::typeshare;
Expand Down Expand Up @@ -145,13 +146,18 @@ impl Tiling {
}

pub fn build(&mut self) -> Result<(), TilingError> {
let start = Utc::now();

let build_result = self
.plane
.build(&self.notation, self.option_expansion_phases);

let end = Utc::now();
let duration: TimeDelta = end - start;

self
.build_context
.add_result(&self.notation, &self.plane, &build_result);
.add_result(&self.notation, &self.plane, &build_result, duration);

build_result
}
Expand Down
1 change: 1 addition & 0 deletions workspaces/tilings/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export interface Result {
transformIndex: number;
uniform: number;
timestamp: string;
buildTimeMs: number;
}

export interface Context {
Expand Down

0 comments on commit 6d82406

Please sign in to comment.