Skip to content

Commit

Permalink
improved time display
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Schüler committed Mar 1, 2024
1 parent ef32d62 commit 4836fc7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 32 deletions.
33 changes: 9 additions & 24 deletions new/src/components/ScenarioOverview/ScenarioCollectionHead.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
import type { ReportStatistics } from "../../reportModel";
import {
Breadcrumbs,
Divider,
Grid,
Link,
List,
ListItem,
ListItemText,
Typography
} from "@mui/material";
import type {ReportStatistics} from "../../reportModel";
import {Breadcrumbs, Divider, Grid, Link, List, ListItem, ListItemText, Typography} from "@mui/material";
import CheckIcon from "@mui/icons-material/CheckBox";
import ErrorIcon from "@mui/icons-material/Error";
import DoNotDisturbAltIcon from "@mui/icons-material/DoNotDisturbAlt";
import { addRuntime } from "../utils";
import RemoveIcon from "@mui/icons-material/Remove";
import AddIcon from "@mui/icons-material/Add";
import PrintOutlinedIcon from "@mui/icons-material/PrintOutlined";
import BookmarkOutlinedIcon from "@mui/icons-material/BookmarkOutlined";
import { createReportCircle } from "./DonutChart";
import { PropsWithChildren } from "react";
import { processWords } from "../../wordProcessor";
import {
StyledContent,
StyledDrawer,
StyledIconButton,
StyledIconContainer,
StyledLink
} from "./ScenarioHead.styles";
import { useFilters } from "../../hooks/useFilters";
import {createReportCircle} from "./DonutChart";
import {PropsWithChildren} from "react";
import {processWords} from "../../wordProcessor";
import {StyledContent, StyledDrawer, StyledIconButton, StyledIconContainer, StyledLink} from "./ScenarioHead.styles";
import {useFilters} from "../../hooks/useFilters";
import {addRuntimeInSeconds} from "../utils";

export enum HeaderIconType {}

Expand Down Expand Up @@ -237,7 +222,7 @@ function StatisticBreadcrumbs(props: { statistic: ReportStatistics }) {
{props.statistic.numPendingScenarios} pending,
</StyledLink>
<Typography color="text.primary">{props.statistic.numScenarios} Total</Typography>
<Typography color={"text.primary"}>{addRuntime(props.statistic)}</Typography>
<Typography color={"text.primary"}>{addRuntimeInSeconds(props.statistic.durationInNanos)}</Typography>
</Breadcrumbs>
);
}
4 changes: 2 additions & 2 deletions new/src/components/Scenarios/Scenario.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type {ScenarioCaseModel, ScenarioModel, StepModel} from "../../reportModel";
import {Accordion, AccordionDetails, Box, Link, Typography} from "@mui/material";
import {useCallback, useEffect, useState} from "react";
import {addRuntime} from "../utils";
import {processWords} from "../../wordProcessor";
import {ExpansionState} from "./ScenarioOverview";
import {ScenarioHead} from "./ScenarioHead";
import {ScenarioCaption} from "./ScenarioCaption";
import {addRuntimeInSeconds} from "../utils";

export interface ScenarioProps {
scenario: ScenarioModel;
Expand Down Expand Up @@ -102,7 +102,7 @@ function ScenarioStep(props: { step: StepModel }) {
const stepDescription = processWords(props.step.words);
return (
<Typography align={"left"}>
{stepDescription} <ScenarioCaption>{addRuntime(props.step)}</ScenarioCaption>
{stepDescription} <ScenarioCaption>{addRuntimeInSeconds(props.step.durationInNanos)}</ScenarioCaption>
</Typography>
);
}
Expand Down
8 changes: 4 additions & 4 deletions new/src/components/Scenarios/ScenarioHead.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Grid, Typography} from "@mui/material";
import { ScenarioModel} from "../../reportModel";
import {Grid, Typography} from "@mui/material";
import {ScenarioModel} from "../../reportModel";
import {processWords} from "../../wordProcessor";
import {StatusIcon} from "../StatusIconSelector";
import {addRuntime} from "../utils";
import {styled} from "@mui/material/styles";
import MuiAccordionSummary, {AccordionSummaryProps} from "@mui/material/AccordionSummary";
import ArrowForwardIosSharpIcon from "@mui/icons-material/ArrowForwardIosSharp";
import {ScenarioCaption} from "./ScenarioCaption";
import {addRuntimeInMiliseconds} from "../utils";

export function ScenarioHead(props: {
scenario: ScenarioModel;
Expand Down Expand Up @@ -48,7 +48,7 @@ export function ScenarioHead(props: {
<StatusIcon executionStatus={props.scenario.executionStatus} />
</Grid>
<Grid>
<ScenarioCaption>{addRuntime(props.scenario.scenarioCases[0])}</ScenarioCaption>
<ScenarioCaption>{addRuntimeInMiliseconds(props.scenario.scenarioCases[0].durationInNanos)}</ScenarioCaption>
</Grid>
</Grid>
</AccordionSummary>
Expand Down
13 changes: 11 additions & 2 deletions new/src/components/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
export function addRuntime(input: { durationInNanos: number }): string {
return input.durationInNanos > 1e7 ? `(${(input.durationInNanos / 1e9).toFixed(3)}s)` : "";
export function addRuntimeInSeconds(durationInNanos: number ): string {
return addRuntime(durationInNanos, 1e7, 1e9, "s");
}

export function addRuntimeInMiliseconds(durationInNanos: number): string {
return addRuntime(durationInNanos, 1e4, 1e6, "ms");
}

function addRuntime(durationInNanos: number, treshhold: number, divisor: number, unitOfMeasure: string): string {
return durationInNanos > treshhold ? `(${(durationInNanos / divisor).toFixed(3)}${unitOfMeasure})` : "";
}

0 comments on commit 4836fc7

Please sign in to comment.