@@ -15,6 +15,7 @@ import (
1515 "regexp"
1616 "strconv"
1717 "strings"
18+ "time"
1819
1920 "perfspect/internal/util"
2021)
@@ -320,23 +321,30 @@ func (m *metricsFromCSV) getHTML(metadata Metadata) (html string, err error) {
320321 {"PKGPOWER" , []string {"package power (watts)" , "package power (watts)" }},
321322 {"DRAMPOWER" , []string {"DRAM power (watts)" , "" }},
322323 }
323- for _ , tmpl := range templateReplace {
324+ for tIdx , tmpl := range templateReplace {
325+ var timeStamps []string
324326 var series [][]float64
325- var firstTimestamp float64
326327 for rIdx , row := range m .rows {
327- if rIdx == 0 {
328- firstTimestamp = row .timestamp
329- }
330328 if math .IsNaN (row.metrics [tmpl.metricNames [archIndex ]]) || math .IsInf (row.metrics [tmpl.metricNames [archIndex ]], 0 ) {
331329 continue
332330 }
333- series = append (series , []float64 {row .timestamp - firstTimestamp , row.metrics [tmpl.metricNames [archIndex ]]})
331+ series = append (series , []float64 {float64 (rIdx ), row.metrics [tmpl.metricNames [archIndex ]]})
332+ // format the UNIX timestamp as a local tz string
333+ ts := time .Unix (int64 (row .timestamp ), 0 ).Format ("15:04:05" )
334+ timeStamps = append (timeStamps , ts )
334335 }
335336 var seriesBytes []byte
336337 if seriesBytes , err = json .Marshal (series ); err != nil {
337338 return
338339 }
339340 html = strings .Replace (html , tmpl .tmplVar , string (seriesBytes ), - 1 )
341+ if tIdx == 0 {
342+ var timeStampsBytes []byte
343+ if timeStampsBytes , err = json .Marshal (timeStamps ); err != nil {
344+ return
345+ }
346+ html = strings .Replace (html , "TIMESTAMPS" , string (timeStampsBytes ), - 1 )
347+ }
340348 }
341349 // All Metrics Tab
342350 var metricHTMLStats [][]string
0 commit comments