2019-03-31 11:00:21 +00:00
|
|
|
|
---
|
|
|
|
|
title: 実行時間の測定
|
|
|
|
|
author: kazu634
|
|
|
|
|
date: 2009-05-24
|
|
|
|
|
wordtwit_post_info:
|
|
|
|
|
- 'O:8:"stdClass":13:{s:6:"manual";b:0;s:11:"tweet_times";i:1;s:5:"delay";i:0;s:7:"enabled";i:1;s:10:"separation";s:2:"60";s:7:"version";s:3:"3.7";s:14:"tweet_template";b:0;s:6:"status";i:2;s:6:"result";a:0:{}s:13:"tweet_counter";i:2;s:13:"tweet_log_ids";a:1:{i:0;i:4611;}s:9:"hash_tags";a:0:{}s:8:"accounts";a:1:{i:0;s:7:"kazu634";}}'
|
|
|
|
|
categories:
|
|
|
|
|
- C
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
<div class="section">
|
|
|
|
|
<p>
|
|
|
|
|
気になったのでメモしておきますね:
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<blockquote title="実行時間測定方法 - 情報系女子大生の一歩先へ" cite="http://d.hatena.ne.jp/to-haku/20090523/p2">
|
|
|
|
|
<p>
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
double gettimeofday_sec(){
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
struct timeval t;
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
gettimeofday(&t, NULL);
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
return (double)t.tv_sec + (double)t.tv_usec * 1e-6;
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
}
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
int main(){
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
double tstart, tend;
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
tstart = gettimeofday_sec(); //開始時間取得
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
/*処理*/
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
tend = gettimeofday_sec(); //終了時間取得
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
printf(“%10.20f”,tend – tstart); //処理時間表示
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
}
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
<cite><a href="http://d.hatena.ne.jp/to-haku/20090523/p2" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://d.hatena.ne.jp/to-haku/20090523/p2', '実行時間測定方法 – 情報系女子大生の一歩先へ');" target="_blank">実行時間測定方法 – 情報系女子大生の一歩先へ</a></cite>
|
|
|
|
|
</p>
|
|
|
|
|
</blockquote>
|
2019-04-02 16:06:15 +00:00
|
|
|
|
</div>
|