User Tools

Site Tools


progrramming:cpp:time

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
progrramming:cpp:time [2022/04/08 12:32]
odagawa removed
— (current)
Line 1: Line 1:
-=====計算時間===== 
  
-自分のコードが遅い場合にプログラムの処理のどの部分が遅いかを確認する方法\\ 
-いくつもあるが,chrono を使ったものを紹介しておく. 
- 
-<code cpp> 
-#include <iostream> 
-#include <chrono> 
- 
-int main ( int argc, char* argv[] ) { 
- 
-  auto time1 = std::chrono::system_clock::now(); 
- 
-  // 処理1 
- 
-  auto time2 = std::chrono::system_clock::now(); 
- 
-  // 処理2 
-   
-  auto time3 = std::chrono::system_clock::now(); 
-   
-  std::cout << "処理1" << std::endl; 
-  std::cout << std::chrono::duration_cast<std::chrono::nanoseconds>(time2 - time1).count() << std::endl; 
-  std::cout << "処理2" << std::endl; 
-  std::cout << std::chrono::duration_cast<std::chrono::nanoseconds>(time3 - time2).count() << std::endl; 
-   
-  std::exit(0); 
- 
-} 
-</code> 
progrramming/cpp/time.1649421164.txt.gz · Last modified: 2022/04/08 12:32 by odagawa