#include <iostream>
#include <chrono>
#include <thread>
int main() {
auto start = std::chrono::high_resolution_clock::now();
// Giả lập công việc với sleep 2 giây
std::this_thread::sleep_for(std::chrono::seconds(2));
auto end = std::chrono::high_resolution_clock::now();
// Đo bằng nhiều đơn vị khác nhau
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
auto us = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
std::cout << "Thời gian (milliseconds): " << ms.count() << "ms" << std::endl;
std::cout << "Thời gian (microseconds): " << us.count() << "µs" << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y2hyb25vPgojaW5jbHVkZSA8dGhyZWFkPgoKaW50IG1haW4oKSB7CiAgICBhdXRvIHN0YXJ0ID0gc3RkOjpjaHJvbm86OmhpZ2hfcmVzb2x1dGlvbl9jbG9jazo6bm93KCk7CiAgICAKICAgIC8vIEdp4bqjIGzhuq1wIGPDtG5nIHZp4buHYyB24bubaSBzbGVlcCAyIGdpw6J5CiAgICBzdGQ6OnRoaXNfdGhyZWFkOjpzbGVlcF9mb3Ioc3RkOjpjaHJvbm86OnNlY29uZHMoMikpOwogICAgCiAgICBhdXRvIGVuZCA9IHN0ZDo6Y2hyb25vOjpoaWdoX3Jlc29sdXRpb25fY2xvY2s6Om5vdygpOwogICAgCiAgICAvLyDEkG8gYuG6sW5nIG5oaeG7gXUgxJHGoW4gduG7iyBraMOhYyBuaGF1CiAgICBhdXRvIG1zID0gc3RkOjpjaHJvbm86OmR1cmF0aW9uX2Nhc3Q8c3RkOjpjaHJvbm86Om1pbGxpc2Vjb25kcz4oZW5kIC0gc3RhcnQpOwogICAgYXV0byB1cyA9IHN0ZDo6Y2hyb25vOjpkdXJhdGlvbl9jYXN0PHN0ZDo6Y2hyb25vOjptaWNyb3NlY29uZHM+KGVuZCAtIHN0YXJ0KTsKICAgIAogICAgc3RkOjpjb3V0IDw8ICJUaOG7nWkgZ2lhbiAobWlsbGlzZWNvbmRzKTogIiA8PCBtcy5jb3VudCgpIDw8ICJtcyIgPDwgc3RkOjplbmRsOwogICAgc3RkOjpjb3V0IDw8ICJUaOG7nWkgZ2lhbiAobWljcm9zZWNvbmRzKTogIiA8PCB1cy5jb3VudCgpIDw8ICLCtXMiIDw8IHN0ZDo6ZW5kbDsKICAgIAogICAgcmV0dXJuIDA7Cn0=