Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
resources
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TDT4102
VS-Code
resources
Commits
a99b1439
Commit
a99b1439
authored
1 year ago
by
bartvbl
Browse files
Options
Downloads
Patches
Plain Diff
Added lecture 14 handout
parent
8c02fe2c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
templates/_folder_Lectures/Lecture 14 - handout/Stopwatch.cpp
+12
-0
12 additions, 0 deletions
...lates/_folder_Lectures/Lecture 14 - handout/Stopwatch.cpp
templates/_folder_Lectures/Lecture 14 - handout/Stopwatch.h
+20
-0
20 additions, 0 deletions
templates/_folder_Lectures/Lecture 14 - handout/Stopwatch.h
with
32 additions
and
0 deletions
templates/_folder_Lectures/Lecture 14 - handout/Stopwatch.cpp
0 → 100644
+
12
−
0
View file @
a99b1439
#include
"Stopwatch.h"
void
Stopwatch
::
start
()
{
startTime
=
std
::
chrono
::
steady_clock
::
now
();
}
double
Stopwatch
::
stop
()
{
std
::
chrono
::
time_point
endTime
=
std
::
chrono
::
steady_clock
::
now
();
long
durationInMicroseconds
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
endTime
-
startTime
).
count
();
double
durationInSeconds
=
double
(
durationInMicroseconds
)
/
1000000.0
;
return
durationInSeconds
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
templates/_folder_Lectures/Lecture 14 - handout/Stopwatch.h
0 → 100644
+
20
−
0
View file @
a99b1439
#pragma once
#include
<iostream>
#include
<chrono>
// This class abstracts some (somewhat) nasty code that is
// definitely outside the scope of this course.
// Its main purpose is to return the amount of time
// taken by the program in main.cpp
// Calling start() starts the stopwatch
// Calling stop() stops it and returns the amount of time
// that has elapsed since start() was called in seconds
class
Stopwatch
{
std
::
chrono
::
time_point
<
std
::
chrono
::
steady_clock
>
startTime
;
public:
void
start
();
double
stop
();
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment