Skip to content

Instantly share code, notes, and snippets.

@alepez
Created January 17, 2019 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alepez/4b44c3d2ec6a56ef527661f591285c2a to your computer and use it in GitHub Desktop.
Save alepez/4b44c3d2ec6a56ef527661f591285c2a to your computer and use it in GitHub Desktop.
Count time between new lines
#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