Skip to content
Snippets Groups Projects
Commit a99b1439 authored by bartvbl's avatar bartvbl
Browse files

Added lecture 14 handout

parent 8c02fe2c
No related branches found
No related tags found
No related merge requests found
#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
#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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment