blog/content/post/2009/05/24/2009-05-24-00001161.md

78 lines
1.6 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
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(&#8220;%10.20f&#8221;,tend &#8211; 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', '実行時間測定方法 &#8211; 情報系女子大生の一歩先へ');" target="_blank">実行時間測定方法 &#8211; 情報系女子大生の一歩先へ</a></cite>
</p>
</blockquote>
</div>