Date and time utilities
提供:cppreference.com
< cpp
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
C + +の時間操作の2つのタイプのサポートが含まれています
Original:
C++ includes support for two types of time manipulation:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
-
chronoライブラリ、種々の精度で時間を追跡するタイプの柔軟なコレクション(例えばstd::chrono::time_point).Original:Thechronolibrary, a flexible collection of types that track time with varying degrees of precision (e.g. std::chrono::time_point).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - C形式の日付と時刻ライブラリ(例えばstd::time)Original:C-style date and time library (e.g. std::time)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
目次 |
[編集] NJライブラリ
chronoライブラリは、主に3つのタイプ(持続時間、時計、タイムポイント)だけでなく、ユーティリティ機能と共通のtypedefを定義しています.Original:
The
chrono library defines three main types (durations, clocks, and time points) as well as utility functions and common typedefs.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 持続
持続時間は、いくつかの時間単位の刻みのいくつかの数で定義されている時間のスパンで構成されています。例えば、 "42秒"は、1秒の時間単位の42ティックから成るデュレーションで表すことができ.
Original:
A duration consists of a span of time, defined as some number of ticks of some time unit. For example, "42 seconds" could be represented by a duration consisting of 42 ticks of a 1-second time unit.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
| Defined in header
<chrono> | |
| Defined in namespace
std::chrono | |
| (C++11) |
時間間隔 Original: a time interval The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (クラステンプレート) |
[編集] クロック
クロックは、開始点(またはエポック)とダニ·レートで構成されています。例えば、クロックは1970年1月1日のエポックを持つと毎秒ダニかもしれません。 C + +の3つのクロック·タイプを定義しています
Original:
A clock consists of a starting point (or epoch) and a tick rate. For example, a clock may have an epoch of January 1, 1970 and tick every second. C++ defines three clock types:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
| Defined in header
<chrono> | |
| Defined in namespace
std::chrono | |
| (C++11) |
システム全体のリアルタイムクロックから壁時計時刻 Original: wall clock time from the system-wide realtime clock The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (クラス) |
| (C++11) |
調整されることはありません単調なクロック Original: monotonic clock that will never be adjusted The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (クラス) |
| (C++11) |
可能な最短のダニ期間付きクロック Original: the clock with the shortest tick period available The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (クラス) |
[編集] 時点
時点では、特定の時計のエポックから経過した時間の長さです.
Original:
A time point is a duration of time that has passed since the epoch of specific clock.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
| Defined in header
<chrono> | |
| Defined in namespace
std::chrono | |
| (C++11) |
a point in time (クラステンプレート) |
[編集] C形式の日付と時刻ライブラリ
また、提供されるようstd::time_tとして、Cスタイルの日付と時刻の関数であり、std::difftime、とCLOCKS_PER_SEC.
Original:
Also provided are the C-style date and time functions, such as std::time_t, std::difftime, and CLOCKS_PER_SEC.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 例
この例では、関数呼び出しの実行時間に関する情報を表示します
Original:
This example displays information about the execution time of a function call:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
#include <iostream> #include <chrono> #include <ctime> int fibonacci(int n) { if (n < 3) return 1; return fibonacci(n-1) + fibonacci(n-2); } int main() { std::chrono::time_point<std::chrono::system_clock> start, end; start = std::chrono::system_clock::now(); int result = fibonacci(42); end = std::chrono::system_clock::now(); int elapsed_seconds = std::chrono::duration_cast<std::chrono::seconds> (end-start).count(); std::time_t end_time = std::chrono::system_clock::to_time_t(end); std::cout << "finished computation at " << std::ctime(&end_time) << "elapsed time: " << elapsed_seconds << "s\n"; }
Possible output:
finished computation at Sat Jun 16 20:42:57 2012 elapsed time: 3s