Tsallaka zuwa abun ciki
Justice Tech School

chrono and filesystem

<chrono> measures time and <filesystem> works with paths and directories (C++17).

Example
#include <chrono>
#include <filesystem>
namespace fs = std::filesystem;
auto t0 = chrono::steady_clock::now();
int s = 0; for (int i = 0; i < 100000; i++) s += i;
auto ms = chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - t0).count();
cout << s << " " << (ms < 1000) << "\n";
fs::path p = "/tmp/demo/file.txt";
cout << p.filename() << " " << p.extension() << " " << p.parent_path() << "\n";

Result

704982704 1
"file.txt" ".txt" "/tmp/demo"

Exercise

Namespace for paths.

namespace fs = std::;

Quiz Test

What does steady_clock measure?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.