中の技術日誌ブログ

C#とC++/CLIと
VBと.NETとWindowsで戯れる
 

目次

Blog 利用状況

ニュース

自己紹介

東京でソフトウェアエンジニアをやっています。
お仕事大募集中です。
記事執筆や、講師依頼とかでも何でもどうぞ(*^_^*)
似顔絵 MSMVPロゴ
MSMVP Visual C# Since 2004/04-2013/03

記事カテゴリ

書庫

日記カテゴリ

00-整理

01-MSMVP

わんくまライブラリ Wankuma.Interop.InteropQueryPerformanceCounter Version1

http://naka.wankuma.com/site/library/dotnet1.1/Wankuma.Interop.InteropQueryPerformanceCounter1d.htm

ソースファイルへ
Wankuma.Interop.InteropQueryPerformanceCounter1s.htm

ソースファイル直接ダウンロードへ
Wankuma.Interop.InteropQueryPerformanceCounter1c.txt

利用規約へ
../kiyaku.htm

クラスの説明

Windows APIの世界でもっとも細かい単位で(分解能という)時間を計測するにはQueryPerformanceCounterを使います。

[HOW TO] Visual C# .NET で、QueryPerformanceCounter を使用してコードの時間を計測する方法
http://support.microsoft.com/kb/306979/ja

[HOW TO] Visual Basic .NET で QueryPerformanceCounter を使用してコードの時間を計測する方法
http://support.microsoft.com/kb/306978/ja

ただしこのKBのままでは使いにくいですので、ラップしました。

メソッドの説明

public void Start()

計測を開始します

public void End()

計測を終了します

プロパティの説明

public long Frequency

分解能を取得します。

public double Result

計測結果を返します

テストコード

C#

Wankuma.Interop.InteropQueryPerformanceCounter iqpc = new Wankuma.Interop.InteropQueryPerformanceCounter();
iqpc.Start(); //計測を開始します
System.Threading.Thread.Sleep(1000);  //時間のかかる処理をします
iqpc.End(); //計測を終了します
double Result = iqpc.Result;
System.Diagnostics.Debug.WriteLine(Result);

VB

Dim iqpc As Wankuma.Interop.InteropQueryPerformanceCounter = New Wankuma.Interop.InteropQueryPerformanceCounter
iqpc.Start()     '計測を開始します
System.Threading.Thread.Sleep(1000)    '時間のかかる処理をします
iqpc.End()      '計測を終了します
Dim Result As Double = iqpc.Result
System.Diagnostics.Debug.WriteLine(Result)

結果

0.999437143266322

投稿日時 : 2005年7月19日 2:11

コメントを追加

# re: わんくまライブラリ Wankuma.Interop.InteropQueryPerformanceCounter Version1 2005/07/19 10:17 じゃんぬ

End メソッドの色が変わってるよん (w

# [.NET] Wankuma.Interop.InteropQueryPerformanceCounter Version1 2005/07/19 18:14 is BUG ready ?

[http://blogs.wankuma.com/naka/archive/2005/07/19/17602.aspx:title]より えーっと、ダウンロードしてないです、ソースは Web からみれるものを1枚見ただけ P/Ivoke の戻り値が short になっていますが API の定義は Windows Types BOOL 型なので、対応する .NET 型は UnmanagedType.Bool へマッピングされなければなりません。これは標準では System.Int32 になっています。こ ...

# FJVwDyIoSikErNEaHTj 2011/12/13 20:48 http://www.drinkershealth.net/naltrexone-revia/

I serched through the internet and got here. What a wonderful invention of the mankind. With the help of the network you communicate, learn, read !... That helped us to get acquainted!...

# kfRCZXXBsaja 2011/12/17 19:14 http://www.youtube.com/theremotemower

It's straight to the point! You could not tell in other words! :D

# iCAJjUtzjEx 2011/12/17 19:51 http://www.coursbatterie.com

It's straight to the point! You could not tell in other words! :D

# gUXyGchPMIcSH 2011/12/18 21:06 http://blackflats.info/

Author, Shoot yourself a knee..!

タイトル
名前
URL
コメント