ホーム › System.Performance › PERF_DATA_BLOCK
PERF_DATA_BLOCK
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Signature | WCHAR | 8 | +0 | +0 | データブロックの署名を表すWCHAR配列("PERF")である。 |
| LittleEndian | DWORD | 4 | +8 | +8 | リトルエンディアンなら非0、ビッグエンディアンなら0となる。 |
| Version | DWORD | 4 | +12 | +12 | データブロック形式のバージョン番号である。 |
| Revision | DWORD | 4 | +16 | +16 | データブロック形式のリビジョン番号である。 |
| TotalByteLength | DWORD | 4 | +20 | +20 | このデータブロックとそれに続く全データの合計バイト長である。 |
| HeaderLength | DWORD | 4 | +24 | +24 | このヘッダ構造体のバイト長である。 |
| NumObjectTypes | DWORD | 4 | +28 | +28 | 続くPERF_OBJECT_TYPEの個数である。 |
| DefaultObject | INT | 4 | +32 | +32 | 既定で表示するオブジェクトの名前タイトルインデックスである。-1で無し。 |
| SystemTime | SYSTEMTIME | 16 | +36 | +36 | データ収集時のシステム時刻を表すSYSTEMTIMEである。 |
| PerfTime | LONGLONG | 8 | +56 | +56 | パフォーマンスカウンタの現在値である。 |
| PerfFreq | LONGLONG | 8 | +64 | +64 | パフォーマンスカウンタの周波数である。 |
| PerfTime100nSec | LONGLONG | 8 | +72 | +72 | 100ナノ秒単位のパフォーマンス時刻である。 |
| SystemNameLength | DWORD | 4 | +80 | +80 | システム名文字列のバイト長である。 |
| SystemNameOffset | DWORD | 4 | +84 | +84 | ブロック先頭からシステム名文字列までのオフセットである。 |
各言語での定義
#include <windows.h>
// SYSTEMTIME (x64 16 / x86 16 バイト)
typedef struct SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME;
// PERF_DATA_BLOCK (x64 88 / x86 88 バイト)
typedef struct PERF_DATA_BLOCK {
WCHAR Signature[4];
DWORD LittleEndian;
DWORD Version;
DWORD Revision;
DWORD TotalByteLength;
DWORD HeaderLength;
DWORD NumObjectTypes;
INT DefaultObject;
SYSTEMTIME SystemTime;
LONGLONG PerfTime;
LONGLONG PerfFreq;
LONGLONG PerfTime100nSec;
DWORD SystemNameLength;
DWORD SystemNameOffset;
} PERF_DATA_BLOCK;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SYSTEMTIME
{
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek;
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMilliseconds;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PERF_DATA_BLOCK
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)] public string Signature;
public uint LittleEndian;
public uint Version;
public uint Revision;
public uint TotalByteLength;
public uint HeaderLength;
public uint NumObjectTypes;
public int DefaultObject;
public SYSTEMTIME SystemTime;
public long PerfTime;
public long PerfFreq;
public long PerfTime100nSec;
public uint SystemNameLength;
public uint SystemNameOffset;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SYSTEMTIME
Public wYear As UShort
Public wMonth As UShort
Public wDayOfWeek As UShort
Public wDay As UShort
Public wHour As UShort
Public wMinute As UShort
Public wSecond As UShort
Public wMilliseconds As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PERF_DATA_BLOCK
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=4)> Public Signature As String
Public LittleEndian As UInteger
Public Version As UInteger
Public Revision As UInteger
Public TotalByteLength As UInteger
Public HeaderLength As UInteger
Public NumObjectTypes As UInteger
Public DefaultObject As Integer
Public SystemTime As SYSTEMTIME
Public PerfTime As Long
Public PerfFreq As Long
Public PerfTime100nSec As Long
Public SystemNameLength As UInteger
Public SystemNameOffset As UInteger
End Structureimport ctypes
from ctypes import wintypes
class SYSTEMTIME(ctypes.Structure):
_fields_ = [
("wYear", ctypes.c_ushort),
("wMonth", ctypes.c_ushort),
("wDayOfWeek", ctypes.c_ushort),
("wDay", ctypes.c_ushort),
("wHour", ctypes.c_ushort),
("wMinute", ctypes.c_ushort),
("wSecond", ctypes.c_ushort),
("wMilliseconds", ctypes.c_ushort),
]
class PERF_DATA_BLOCK(ctypes.Structure):
_fields_ = [
("Signature", ctypes.c_wchar * 4),
("LittleEndian", wintypes.DWORD),
("Version", wintypes.DWORD),
("Revision", wintypes.DWORD),
("TotalByteLength", wintypes.DWORD),
("HeaderLength", wintypes.DWORD),
("NumObjectTypes", wintypes.DWORD),
("DefaultObject", ctypes.c_int),
("SystemTime", SYSTEMTIME),
("PerfTime", ctypes.c_longlong),
("PerfFreq", ctypes.c_longlong),
("PerfTime100nSec", ctypes.c_longlong),
("SystemNameLength", wintypes.DWORD),
("SystemNameOffset", wintypes.DWORD),
]#[repr(C)]
pub struct SYSTEMTIME {
pub wYear: u16,
pub wMonth: u16,
pub wDayOfWeek: u16,
pub wDay: u16,
pub wHour: u16,
pub wMinute: u16,
pub wSecond: u16,
pub wMilliseconds: u16,
}
#[repr(C)]
pub struct PERF_DATA_BLOCK {
pub Signature: [u16; 4],
pub LittleEndian: u32,
pub Version: u32,
pub Revision: u32,
pub TotalByteLength: u32,
pub HeaderLength: u32,
pub NumObjectTypes: u32,
pub DefaultObject: i32,
pub SystemTime: SYSTEMTIME,
pub PerfTime: i64,
pub PerfFreq: i64,
pub PerfTime100nSec: i64,
pub SystemNameLength: u32,
pub SystemNameOffset: u32,
}import "golang.org/x/sys/windows"
type SYSTEMTIME struct {
wYear uint16
wMonth uint16
wDayOfWeek uint16
wDay uint16
wHour uint16
wMinute uint16
wSecond uint16
wMilliseconds uint16
}
type PERF_DATA_BLOCK struct {
Signature [4]uint16
LittleEndian uint32
Version uint32
Revision uint32
TotalByteLength uint32
HeaderLength uint32
NumObjectTypes uint32
DefaultObject int32
SystemTime SYSTEMTIME
PerfTime int64
PerfFreq int64
PerfTime100nSec int64
SystemNameLength uint32
SystemNameOffset uint32
}type
SYSTEMTIME = record
wYear: Word;
wMonth: Word;
wDayOfWeek: Word;
wDay: Word;
wHour: Word;
wMinute: Word;
wSecond: Word;
wMilliseconds: Word;
end;
PERF_DATA_BLOCK = record
Signature: array[0..3] of WideChar;
LittleEndian: DWORD;
Version: DWORD;
Revision: DWORD;
TotalByteLength: DWORD;
HeaderLength: DWORD;
NumObjectTypes: DWORD;
DefaultObject: Integer;
SystemTime: SYSTEMTIME;
PerfTime: Int64;
PerfFreq: Int64;
PerfTime100nSec: Int64;
SystemNameLength: DWORD;
SystemNameOffset: DWORD;
end;const SYSTEMTIME = extern struct {
wYear: u16,
wMonth: u16,
wDayOfWeek: u16,
wDay: u16,
wHour: u16,
wMinute: u16,
wSecond: u16,
wMilliseconds: u16,
};
const PERF_DATA_BLOCK = extern struct {
Signature: [4]u16,
LittleEndian: u32,
Version: u32,
Revision: u32,
TotalByteLength: u32,
HeaderLength: u32,
NumObjectTypes: u32,
DefaultObject: i32,
SystemTime: SYSTEMTIME,
PerfTime: i64,
PerfFreq: i64,
PerfTime100nSec: i64,
SystemNameLength: u32,
SystemNameOffset: u32,
};type
SYSTEMTIME {.bycopy.} = object
wYear: uint16
wMonth: uint16
wDayOfWeek: uint16
wDay: uint16
wHour: uint16
wMinute: uint16
wSecond: uint16
wMilliseconds: uint16
PERF_DATA_BLOCK {.bycopy.} = object
Signature: array[4, uint16]
LittleEndian: uint32
Version: uint32
Revision: uint32
TotalByteLength: uint32
HeaderLength: uint32
NumObjectTypes: uint32
DefaultObject: int32
SystemTime: SYSTEMTIME
PerfTime: int64
PerfFreq: int64
PerfTime100nSec: int64
SystemNameLength: uint32
SystemNameOffset: uint32struct SYSTEMTIME
{
ushort wYear;
ushort wMonth;
ushort wDayOfWeek;
ushort wDay;
ushort wHour;
ushort wMinute;
ushort wSecond;
ushort wMilliseconds;
}
struct PERF_DATA_BLOCK
{
wchar[4] Signature;
uint LittleEndian;
uint Version;
uint Revision;
uint TotalByteLength;
uint HeaderLength;
uint NumObjectTypes;
int DefaultObject;
SYSTEMTIME SystemTime;
long PerfTime;
long PerfFreq;
long PerfTime100nSec;
uint SystemNameLength;
uint SystemNameOffset;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PERF_DATA_BLOCK サイズ: 88 バイト(x64)
dim st, 22 ; 4byte整数×22(構造体サイズ 88 / 4 切り上げ)
; Signature : WCHAR (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; LittleEndian : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; Version : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; Revision : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; TotalByteLength : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; HeaderLength : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; NumObjectTypes : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; DefaultObject : INT (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; SystemTime : SYSTEMTIME (+36, 16byte) varptr(st)+36 を基点に操作(16byte:入れ子/配列)
; PerfTime : LONGLONG (+56, 8byte) qpoke st,56,値 / qpeek(st,56) ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; PerfFreq : LONGLONG (+64, 8byte) qpoke st,64,値 / qpeek(st,64) ※IronHSPのみ。3.7/3.8は lpoke st,64,下位 : lpoke st,68,上位
; PerfTime100nSec : LONGLONG (+72, 8byte) qpoke st,72,値 / qpeek(st,72) ※IronHSPのみ。3.7/3.8は lpoke st,72,下位 : lpoke st,76,上位
; SystemNameLength : DWORD (+80, 4byte) st.20 = 値 / 値 = st.20 (lpoke/lpeek も可)
; SystemNameOffset : DWORD (+84, 4byte) st.21 = 値 / 値 = st.21 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global SYSTEMTIME
#field short wYear
#field short wMonth
#field short wDayOfWeek
#field short wDay
#field short wHour
#field short wMinute
#field short wSecond
#field short wMilliseconds
#endstruct
#defstruct global PERF_DATA_BLOCK
#field wchar Signature 4
#field int LittleEndian
#field int Version
#field int Revision
#field int TotalByteLength
#field int HeaderLength
#field int NumObjectTypes
#field int DefaultObject
#field SYSTEMTIME SystemTime
#field int64 PerfTime
#field int64 PerfFreq
#field int64 PerfTime100nSec
#field int SystemNameLength
#field int SystemNameOffset
#endstruct
stdim st, PERF_DATA_BLOCK ; NSTRUCT 変数を確保
st->LittleEndian = 100
mes "LittleEndian=" + st->LittleEndian