Merge lp:~nik90/ubuntu-clock-app/migrate-stopwatch-utils-c++ into lp:ubuntu-clock-app

Proposed by Nekhelesh Ramananthan
Status: Merged
Approved by: Bartosz Kosiorek
Approved revision: 367
Merged at revision: 361
Proposed branch: lp:~nik90/ubuntu-clock-app/migrate-stopwatch-utils-c++
Merge into: lp:ubuntu-clock-app
Diff against target: 498 lines (+163/-113)
11 files modified
app/stopwatch/CMakeLists.txt (+0/-1)
app/stopwatch/LapListView.qml (+7/-6)
app/stopwatch/StopwatchFace.qml (+5/-4)
app/stopwatch/StopwatchPage.qml (+1/-1)
app/stopwatch/StopwatchUtils.qml (+0/-73)
backend/CMakeLists.txt (+13/-12)
backend/modules/Stopwatch/backend.cpp (+3/-1)
backend/modules/Stopwatch/formattime.cpp (+78/-0)
backend/modules/Stopwatch/formattime.h (+38/-0)
backend/modules/Stopwatch/qmldir (+2/-2)
tests/unit/tst_stopwatchUtils.qml (+16/-13)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/migrate-stopwatch-utils-c++
Reviewer Review Type Date Requested Status
Bartosz Kosiorek Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+269051@code.launchpad.net

Commit message

Converted StopwatchUtils.qml functions to C++ functions to shave loading times and improve performance by a tiny bit.

Description of the change

This MP converts the StopwatchUtils.qml functions to C++ functions for the following reasons,

When I ran stopwatch using Qt Profiler, I noticed that StopwatchUtils{} takes around 60 ms to load, and each function call within takes an average of 200 microsecond. On converting this to c++, the load time reduces to 500 microseconds, so from 60ms->500microsecond! And each function call takes half the time (100 microsecond)

While the performance shaving are quite small, it raises the question as to why not do this change? I see no disadvantages. Nothing in the qml side needs to be changed, unit tests pass. Regression free!

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
364. By Nekhelesh Ramananthan

Changed StopwatchUtils to just Utils

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
365. By Nekhelesh Ramananthan

Renamed Utils to FormatTime

366. By Nekhelesh Ramananthan

Fixed hours being truncated when they are greater than 99

367. By Nekhelesh Ramananthan

Fixed unit tests

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

works perfectly for me, and everrything is fine according to checklist

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'app/stopwatch/CMakeLists.txt'
--- app/stopwatch/CMakeLists.txt 2015-08-09 20:59:10 +0000
+++ app/stopwatch/CMakeLists.txt 2015-08-26 22:51:08 +0000
@@ -2,7 +2,6 @@
2 LapListView.qml2 LapListView.qml
3 StopwatchFace.qml3 StopwatchFace.qml
4 StopwatchPage.qml4 StopwatchPage.qml
5 StopwatchUtils.qml
6)5)
76
8# make the files visible in the qtcreator tree7# make the files visible in the qtcreator tree
98
=== modified file 'app/stopwatch/LapListView.qml'
--- app/stopwatch/LapListView.qml 2015-08-20 19:59:21 +0000
+++ app/stopwatch/LapListView.qml 2015-08-26 22:51:08 +0000
@@ -19,14 +19,15 @@
19import QtQuick 2.419import QtQuick 2.4
20import QtQuick.Layouts 1.120import QtQuick.Layouts 1.1
21import Ubuntu.Components 1.221import Ubuntu.Components 1.2
22import Stopwatch 1.0
2223
23ListView {24ListView {
24 id: lapListView25 id: lapListView
2526
26 clip: true27 clip: true
2728
28 StopwatchUtils {29 StopwatchFormatTime {
29 id: stopwatchUtils30 id: stopwatchFormatTime
30 }31 }
3132
32 header: ListItem {33 header: ListItem {
@@ -108,11 +109,11 @@
108 Row {109 Row {
109 anchors.horizontalCenter: parent.horizontalCenter110 anchors.horizontalCenter: parent.horizontalCenter
110 Label {111 Label {
111 text: stopwatchUtils.lapTimeToString(model.laptime) + "."112 text: stopwatchFormatTime.lapTimeToString(model.laptime) + "."
112 }113 }
113 Label {114 Label {
114 fontSize: "x-small"115 fontSize: "x-small"
115 text: stopwatchUtils.millisToString(model.laptime)116 text: stopwatchFormatTime.millisToString(model.laptime)
116 anchors.bottom: parent.bottom117 anchors.bottom: parent.bottom
117 anchors.bottomMargin: units.dp(1)118 anchors.bottomMargin: units.dp(1)
118 }119 }
@@ -125,11 +126,11 @@
125 Row {126 Row {
126 anchors.horizontalCenter: parent.horizontalCenter127 anchors.horizontalCenter: parent.horizontalCenter
127 Label {128 Label {
128 text: stopwatchUtils.lapTimeToString(model.totaltime) + "."129 text: stopwatchFormatTime.lapTimeToString(model.totaltime) + "."
129 }130 }
130 Label {131 Label {
131 fontSize: "x-small"132 fontSize: "x-small"
132 text: stopwatchUtils.millisToString(model.totaltime)133 text: stopwatchFormatTime.millisToString(model.totaltime)
133 anchors.bottom: parent.bottom134 anchors.bottom: parent.bottom
134 anchors.bottomMargin: units.dp(1)135 anchors.bottomMargin: units.dp(1)
135 }136 }
136137
=== modified file 'app/stopwatch/StopwatchFace.qml'
--- app/stopwatch/StopwatchFace.qml 2015-08-17 20:27:12 +0000
+++ app/stopwatch/StopwatchFace.qml 2015-08-26 22:51:08 +0000
@@ -17,6 +17,7 @@
17 */17 */
1818
19import QtQuick 2.419import QtQuick 2.4
20import Stopwatch 1.0
20import Ubuntu.Components 1.221import Ubuntu.Components 1.2
21import "../components"22import "../components"
2223
@@ -29,8 +30,8 @@
29 isOuter: true30 isOuter: true
30 width: units.gu(32)31 width: units.gu(32)
3132
32 StopwatchUtils {33 StopwatchFormatTime {
33 id: stopwatchUtils34 id: stopwatchFormatTime
34 }35 }
3536
36 ClockCircle {37 ClockCircle {
@@ -46,13 +47,13 @@
46 anchors.centerIn: parent47 anchors.centerIn: parent
4748
48 Label {49 Label {
49 text: stopwatchUtils.millisToTimeString(milliseconds, false, true)50 text: stopwatchFormatTime.millisToTimeString(milliseconds, true)
50 font.pixelSize: units.dp(34)51 font.pixelSize: units.dp(34)
51 color: UbuntuColors.midAubergine52 color: UbuntuColors.midAubergine
52 }53 }
5354
54 Label {55 Label {
55 text: stopwatchUtils.millisToString(milliseconds)56 text: stopwatchFormatTime.millisToString(milliseconds)
56 font.pixelSize: units.dp(18)57 font.pixelSize: units.dp(18)
57 color: UbuntuColors.midAubergine58 color: UbuntuColors.midAubergine
58 anchors.horizontalCenter: parent.horizontalCenter59 anchors.horizontalCenter: parent.horizontalCenter
5960
=== modified file 'app/stopwatch/StopwatchPage.qml'
--- app/stopwatch/StopwatchPage.qml 2015-08-18 13:13:32 +0000
+++ app/stopwatch/StopwatchPage.qml 2015-08-26 22:51:08 +0000
@@ -17,8 +17,8 @@
17 */17 */
1818
19import QtQuick 2.419import QtQuick 2.4
20import Stopwatch 1.0
20import Ubuntu.Components 1.221import Ubuntu.Components 1.2
21import Stopwatch.LapHistory 1.0
2222
23Item {23Item {
24 id: _stopwatchPage24 id: _stopwatchPage
2525
=== removed file 'app/stopwatch/StopwatchUtils.qml'
--- app/stopwatch/StopwatchUtils.qml 2015-08-17 20:27:12 +0000
+++ app/stopwatch/StopwatchUtils.qml 1970-01-01 00:00:00 +0000
@@ -1,73 +0,0 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This file is part of Ubuntu Clock App
5 *
6 * Ubuntu Clock App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Ubuntu Clock App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 2.4
20import Ubuntu.Components 1.2
21
22/*
23 Qt Object containing a collection of useful stopwatch functions
24*/
25QtObject {
26 id: stopwatchUtils
27
28 // Function to return only the milliseconds
29 function millisToString(millis) {
30 return addZeroPrefix(millis % 1000, 3)
31 }
32
33 // Function to break down time (milliseconds) to hours, minutes and seconds
34 function millisToTimeString(millis, showMilliseconds, showHours) {
35 var hours, minutes, seconds
36
37 // Break down total time (milliseconds) to hours, minutes and seconds
38 seconds = Math.floor(millis / 1000) % 60;
39 minutes = Math.floor(millis / 1000 / 60) % 60
40 hours = Math.floor(millis / 1000 / 60 / 60)
41
42 // Build the time string
43 var timeString = ""
44
45 if (showHours) {
46 timeString += addZeroPrefix(hours, 2) + ":"
47 }
48
49 timeString += addZeroPrefix(minutes, 2) + ":"
50 timeString += addZeroPrefix(seconds, 2)
51
52 if (showMilliseconds) {
53 timeString += "." + millisToString(millis)
54 }
55
56 return timeString
57 }
58
59 // Function to add zero prefix if necessary.
60 function addZeroPrefix (str, totalLength) {
61 return ("00000" + str).slice(-totalLength)
62 }
63
64 // Function to return lap time as a string
65 function lapTimeToString(millis) {
66 var hours = hours = Math.floor(millis / 1000 / 60 / 60)
67 if (hours > 0) {
68 return millisToTimeString(millis, false, true)
69 } else {
70 return millisToTimeString(millis, false, false)
71 }
72 }
73}
740
=== modified file 'backend/CMakeLists.txt'
--- backend/CMakeLists.txt 2015-08-24 15:08:21 +0000
+++ backend/CMakeLists.txt 2015-08-26 22:51:08 +0000
@@ -41,9 +41,10 @@
41)41)
4242
43set(43set(
44 stopwatchlaphistory_SRCS44 stopwatch_SRCS
45 modules/Stopwatch/LapHistory/backend.cpp45 modules/Stopwatch/backend.cpp
46 modules/Stopwatch/LapHistory/history.cpp46 modules/Stopwatch/history.cpp
47 modules/Stopwatch/formattime.cpp
47)48)
4849
49add_library(timezone MODULE50add_library(timezone MODULE
@@ -66,8 +67,8 @@
66 ${clockutility_SRCS}67 ${clockutility_SRCS}
67)68)
6869
69add_library(stopwatchlaphistory MODULE70add_library(stopwatch MODULE
70 ${stopwatchlaphistory_SRCS}71 ${stopwatch_SRCS}
71)72)
7273
73set_target_properties(timezone PROPERTIES74set_target_properties(timezone PROPERTIES
@@ -90,8 +91,8 @@
90 LIBRARY_OUTPUT_DIRECTORY Clock/Utility91 LIBRARY_OUTPUT_DIRECTORY Clock/Utility
91)92)
9293
93set_target_properties(stopwatchlaphistory PROPERTIES94set_target_properties(stopwatch PROPERTIES
94 LIBRARY_OUTPUT_DIRECTORY Stopwatch/LapHistory95 LIBRARY_OUTPUT_DIRECTORY Stopwatch/
95)96)
9697
97qt5_use_modules(datetime Gui Qml Quick)98qt5_use_modules(datetime Gui Qml Quick)
@@ -99,7 +100,7 @@
99qt5_use_modules(alarmsettings Gui Qml Quick DBus)100qt5_use_modules(alarmsettings Gui Qml Quick DBus)
100qt5_use_modules(geolocation Gui Qml Quick)101qt5_use_modules(geolocation Gui Qml Quick)
101qt5_use_modules(clockutility Qml)102qt5_use_modules(clockutility Qml)
102qt5_use_modules(stopwatchlaphistory Qml)103qt5_use_modules(stopwatch Qml)
103104
104# Copy qmldir file to build dir for running in QtCreator105# Copy qmldir file to build dir for running in QtCreator
105add_custom_target(timezone-qmldir ALL106add_custom_target(timezone-qmldir ALL
@@ -127,8 +128,8 @@
127 DEPENDS ${QMLFILES}128 DEPENDS ${QMLFILES}
128)129)
129130
130add_custom_target(stopwatchlaphistory-qmldir ALL131add_custom_target(stopwatch-qmldir ALL
131 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/modules/Stopwatch/LapHistory/qmldir ${CMAKE_CURRENT_BINARY_DIR}/Stopwatch/LapHistory132 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/modules/Stopwatch/qmldir ${CMAKE_CURRENT_BINARY_DIR}/Stopwatch
132 DEPENDS ${QMLFILES}133 DEPENDS ${QMLFILES}
133)134)
134135
@@ -148,6 +149,6 @@
148install(TARGETS clockutility DESTINATION ${MODULE_PATH}/Clock/Utility/)149install(TARGETS clockutility DESTINATION ${MODULE_PATH}/Clock/Utility/)
149install(FILES modules/Clock/Utility/qmldir DESTINATION ${MODULE_PATH}/Clock/Utility/)150install(FILES modules/Clock/Utility/qmldir DESTINATION ${MODULE_PATH}/Clock/Utility/)
150151
151install(TARGETS stopwatchlaphistory DESTINATION ${MODULE_PATH}/Stopwatch/LapHistory/)152install(TARGETS stopwatch DESTINATION ${MODULE_PATH}/Stopwatch/)
152install(FILES modules/Stopwatch/LapHistory/qmldir DESTINATION ${MODULE_PATH}/Stopwatch/LapHistory/)153install(FILES modules/Stopwatch/qmldir DESTINATION ${MODULE_PATH}/Stopwatch/)
153154
154155
=== removed directory 'backend/modules/Stopwatch/LapHistory'
=== renamed file 'backend/modules/Stopwatch/LapHistory/backend.cpp' => 'backend/modules/Stopwatch/backend.cpp'
--- backend/modules/Stopwatch/LapHistory/backend.cpp 2015-08-18 05:03:59 +0000
+++ backend/modules/Stopwatch/backend.cpp 2015-08-26 22:51:08 +0000
@@ -20,12 +20,14 @@
20#include <QtQml/QQmlContext>20#include <QtQml/QQmlContext>
21#include "backend.h"21#include "backend.h"
22#include "history.h"22#include "history.h"
23#include "formattime.h"
2324
24void BackendPlugin::registerTypes(const char *uri)25void BackendPlugin::registerTypes(const char *uri)
25{26{
26 Q_ASSERT(uri == QLatin1String("Stopwatch.LapHistory"));27 Q_ASSERT(uri == QLatin1String("Stopwatch"));
2728
28 qmlRegisterType<LapHistory>(uri, 1, 0, "LapHistory");29 qmlRegisterType<LapHistory>(uri, 1, 0, "LapHistory");
30 qmlRegisterType<FormatTime>(uri, 1, 0, "StopwatchFormatTime");
29}31}
3032
31void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri)33void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
3234
=== renamed file 'backend/modules/Stopwatch/LapHistory/backend.h' => 'backend/modules/Stopwatch/backend.h'
=== added file 'backend/modules/Stopwatch/formattime.cpp'
--- backend/modules/Stopwatch/formattime.cpp 1970-01-01 00:00:00 +0000
+++ backend/modules/Stopwatch/formattime.cpp 2015-08-26 22:51:08 +0000
@@ -0,0 +1,78 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This file is part of Ubuntu Clock App
5 *
6 * Ubuntu Clock App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Ubuntu Clock App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "formattime.h"
20
21#include <QtMath>
22
23FormatTime::FormatTime(QObject *parent):
24 QObject(parent)
25{
26}
27
28QString FormatTime::millisToString(int millis) const
29{
30 return addZeroPrefix(QString::number(millis), 3);
31}
32
33QString FormatTime::millisToTimeString(int millis, bool showHours) const
34{
35 int hours, minutes, seconds;
36
37 seconds = qFloor(millis / 1000) % 60;
38 minutes = qFloor(millis / 1000 / 60) % 60;
39 hours = qFloor(millis / 1000 / 60 / 60);
40
41 QString timeString("");
42
43 if (showHours)
44 {
45 if (hours < 10)
46 {
47 timeString += addZeroPrefix(QString::number(hours), 2) + ":";
48 }
49
50 else {
51 timeString += QString::number(hours) + ":";
52 }
53 }
54
55 timeString += addZeroPrefix(QString::number(minutes), 2) + ":";
56 timeString += addZeroPrefix(QString::number(seconds), 2);
57
58 return timeString;
59}
60
61QString FormatTime::addZeroPrefix(QString str, int totalLength) const
62{
63 return QString("00000" + str).remove(0, 5 + str.length() - totalLength);
64}
65
66QString FormatTime::lapTimeToString(int millis) const
67{
68 int hours = qFloor(millis / 1000 / 60 / 60);
69
70 if (hours > 0)
71 {
72 return millisToTimeString(millis, true);
73 }
74
75 else {
76 return millisToTimeString(millis, false);
77 }
78}
079
=== added file 'backend/modules/Stopwatch/formattime.h'
--- backend/modules/Stopwatch/formattime.h 1970-01-01 00:00:00 +0000
+++ backend/modules/Stopwatch/formattime.h 2015-08-26 22:51:08 +0000
@@ -0,0 +1,38 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This file is part of Ubuntu Clock App
5 *
6 * Ubuntu Clock App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Ubuntu Clock App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef FORMATTIME_H
20#define FORMATTIME_H
21
22#include <QObject>
23
24class FormatTime: public QObject
25{
26 Q_OBJECT
27
28public:
29 FormatTime(QObject *parent=0);
30
31public slots:
32 QString millisToString(int millis) const;
33 QString millisToTimeString(int millis, bool showHours) const;
34 QString addZeroPrefix(QString str, int totalLength) const;
35 QString lapTimeToString(int millis) const;
36};
37
38#endif
039
=== renamed file 'backend/modules/Stopwatch/LapHistory/history.cpp' => 'backend/modules/Stopwatch/history.cpp'
=== renamed file 'backend/modules/Stopwatch/LapHistory/history.h' => 'backend/modules/Stopwatch/history.h'
=== renamed file 'backend/modules/Stopwatch/LapHistory/qmldir' => 'backend/modules/Stopwatch/qmldir'
--- backend/modules/Stopwatch/LapHistory/qmldir 2015-08-18 05:03:59 +0000
+++ backend/modules/Stopwatch/qmldir 2015-08-26 22:51:08 +0000
@@ -1,2 +1,2 @@
1module Stopwatch.LapHistory1module Stopwatch
2plugin stopwatchlaphistory2plugin stopwatch
33
=== modified file 'tests/unit/tst_stopwatchUtils.qml'
--- tests/unit/tst_stopwatchUtils.qml 2015-08-17 20:27:12 +0000
+++ tests/unit/tst_stopwatchUtils.qml 2015-08-26 22:51:08 +0000
@@ -18,15 +18,16 @@
1818
19import QtQuick 2.419import QtQuick 2.4
20import QtTest 1.020import QtTest 1.0
21import Stopwatch 1.0
21import Ubuntu.Components 1.222import Ubuntu.Components 1.2
22import "../../app/stopwatch"23import "../../app/stopwatch"
2324
24TestCase {25TestCase {
25 id: stopwatchUtilsTest26 id: stopwatchFormatTimeTest
26 name: "StopwatchUtilsLibrary"27 name: "StopwatchFormatTimeLibrary"
2728
28 StopwatchUtils {29 StopwatchFormatTime {
29 id: stopwatchUtils30 id: stopwatchFormatTime
30 }31 }
3132
32 /*33 /*
@@ -35,9 +36,9 @@
35 */36 */
36 function test_returnMillisecond() {37 function test_returnMillisecond() {
37 var result38 var result
38 result = stopwatchUtils.millisToString(400)39 result = stopwatchFormatTime.millisToString(400)
39 compare(result, "400", "Milliseconds not properly converted to the format required")40 compare(result, "400", "Milliseconds not properly converted to the format required")
40 result = stopwatchUtils.millisToString(4)41 result = stopwatchFormatTime.millisToString(4)
41 compare(result, "004", "Milliseconds not properly converted to the format required")42 compare(result, "004", "Milliseconds not properly converted to the format required")
42 }43 }
4344
@@ -46,9 +47,11 @@
46 correctly.47 correctly.
47 */48 */
48 function test_convertTimeInMillisecondsToString() {49 function test_convertTimeInMillisecondsToString() {
49 var timeInMilliseconds = 112300050 var timeInMilliseconds = 1123000, result
50 var result = stopwatchUtils.millisToTimeString(timeInMilliseconds, false, true)51 result = stopwatchFormatTime.millisToTimeString(timeInMilliseconds, true)
51 compare(result, "00:18:43", "Time not properly converted from milliseconds to hh:mm:ss")52 compare(result, "00:18:43", "Time not properly converted from milliseconds to hh:mm:ss")
53 result = stopwatchFormatTime.millisToTimeString(timeInMilliseconds, false)
54 compare(result, "18:43", "Time not properly converted from milliseconds to mm:ss")
52 }55 }
5356
54 /*57 /*
@@ -57,11 +60,11 @@
57 */60 */
58 function test_zeroPrefixAddedCorrectly() {61 function test_zeroPrefixAddedCorrectly() {
59 var str = "32", result62 var str = "32", result
60 result = stopwatchUtils.addZeroPrefix(str, 2)63 result = stopwatchFormatTime.addZeroPrefix(str, 2)
61 compare(result, "32", "Zero prefix not added correctly")64 compare(result, "32", "Zero prefix not added correctly")
62 result = stopwatchUtils.addZeroPrefix(str, 3)65 result = stopwatchFormatTime.addZeroPrefix(str, 3)
63 compare(result, "032", "Zero prefix not added correctly")66 compare(result, "032", "Zero prefix not added correctly")
64 result = stopwatchUtils.addZeroPrefix(str, 4)67 result = stopwatchFormatTime.addZeroPrefix(str, 4)
65 compare(result, "0032", "Zero prefix not added correctly")68 compare(result, "0032", "Zero prefix not added correctly")
66 }69 }
6770
@@ -71,9 +74,9 @@
71 */74 */
72 function test_lapTimeIncludesHoursCorrectly() {75 function test_lapTimeIncludesHoursCorrectly() {
73 var result76 var result
74 result = stopwatchUtils.lapTimeToString(1123000)77 result = stopwatchFormatTime.lapTimeToString(1123000)
75 compare(result, "18:43", "Lap time shows hours despite it not being greater than 0")78 compare(result, "18:43", "Lap time shows hours despite it not being greater than 0")
76 result = stopwatchUtils.lapTimeToString(8323000)79 result = stopwatchFormatTime.lapTimeToString(8323000)
77 compare(result, "02:18:43", "Lap time not showing hours despite it being greater than 0")80 compare(result, "02:18:43", "Lap time not showing hours despite it being greater than 0")
78 }81 }
79}82}

Subscribers

People subscribed via source and target branches