競プロをやるときVscodeでC++の実行時間を知りたいと思いインターネットで調べ実行時間を計測する方法を学び取り入れたのですがVscodeで実行したときとAtcoderのコードテストのページで実行した時の実行時間が違ってしまいます。
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(long long int i = 0; i < n; i++) #define repr(i, a, b) for (long long int i = a; i < b; i++) #define repi(i, a, b) for(long long int i = a; i<=b; i++) typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } int main(){ std::chrono::system_clock::time_point start, end; std::time_t time_stamp; start = std::chrono::system_clock::now(); // 計測開始時間 // ======================= // 計測したい処理 // ======================= int N[5]; N[0] = 1; N[1] = 2; N[1] = N[0]; cout << N[1] << endl; end = std::chrono::system_clock::now(); // 計測終了時間 // 処理に要した時間 auto time = end - start; // 処理を開始した時間(タイムスタンプ) time_stamp = std::chrono::system_clock::to_time_t(start); std::cout << std::ctime(&time_stamp); // 処理に要した時間をミリ秒に変換 auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count(); std::cout << msec << " msec" << std::endl; return 0; }
これをVscoe上で行うと0mescとなります。同様にこのコードをAtcoderのコードテストページで実行すると0mescとなります。しかし、写真のようにサイト上に出ている値と実行時間が一致しません。
どうすれば実行時間をコードテストのページと同じようにできるでしょうか?何が原因なんでしょうか?
まだ回答がついていません
会員登録して回答してみよう