Created
January 17, 2019 13:40
-
-
Save alepez/4b44c3d2ec6a56ef527661f591285c2a to your computer and use it in GitHub Desktop.
Count time between new lines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <chrono> | |
#include <iostream> | |
#include <thread> | |
int main() { | |
using namespace std::chrono; | |
std::string line; | |
auto t = steady_clock::now(); | |
while (std::cin >> line) { | |
const auto now = steady_clock::now(); | |
const auto diff = now - t; | |
t = now; | |
const auto millisec = duration_cast<milliseconds>(diff).count(); | |
std::cout << millisec << std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment