From 80e1f9c81da135ed9a2e19971d451ea8393b6238 Mon Sep 17 00:00:00 2001 From: c-bata Date: Sun, 28 Feb 2021 18:45:46 +0900 Subject: [PATCH] Add duration column --- .../static/components/StudyDetail.tsx | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/optuna_dashboard/static/components/StudyDetail.tsx b/optuna_dashboard/static/components/StudyDetail.tsx index d4068fec..bd47d1ae 100644 --- a/optuna_dashboard/static/components/StudyDetail.tsx +++ b/optuna_dashboard/static/components/StudyDetail.tsx @@ -284,6 +284,46 @@ const TrialTable: FC<{ studyDetail: StudyDetail | null }> = ({ })) columns.push(...objectiveColumns) } + columns.push({ + field: "datetime_start", + label: "Duration(ms)", + toCellValue: (i) => { + const startMs = trials[i].datetime_start?.getTime() + const completeMs = trials[i].datetime_complete?.getTime() + if (startMs !== undefined && completeMs !== undefined) { + return (completeMs - startMs).toString() + } + return null + }, + sortable: true, + less: (i, j): number => { + const firstStartMs = trials[i].datetime_start?.getTime() + const firstCompleteMs = trials[i].datetime_complete?.getTime() + const firstDurationMs = + firstStartMs !== undefined && firstCompleteMs !== undefined + ? firstCompleteMs - firstStartMs + : undefined + const secondStartMs = trials[j].datetime_start?.getTime() + const secondCompleteMs = trials[j].datetime_complete?.getTime() + const secondDurationMs = + secondStartMs !== undefined && secondCompleteMs !== undefined + ? secondCompleteMs - secondStartMs + : undefined + + if (firstDurationMs === secondDurationMs) { + return 0 + } else if ( + firstDurationMs !== undefined && + secondDurationMs !== undefined + ) { + return firstDurationMs < secondDurationMs ? 1 : -1 + } else if (firstDurationMs !== undefined) { + return -1 + } else { + return 1 + } + }, + }) columns.push({ field: "params", label: "Params",