Re: [請益] 想請問如何計算組語執行的時間
※ 引述《c5hyzz (jzz)》之銘言:
: ※ 引述《c5hyzz (jzz)》之銘言:
: : 我現在有一 c 程式透過 gcc 編譯後,可以看到它的組合語言,我想要聊解怎樣去計算整個
: : 程式要花多少 clock才能跑完,我的cpu是 Pentium M,如果有人知道怎麼算請告訴我,謝謝
: 謝謝回答,但是因為我很菜,可不可以詳細一點,謝謝
我通常都是跟C語言混合使用
這是Win32 MSVC用法
#include <windows.h>
#include <stdio.h>
__inline __int64 GetTime() { __asm rdtsc }
__declspec(naked) void test() {
  __asm {
    // assembly code
  }
}
int main() {
  __int64 timeV;
  HANDLE thisthread=GetCurrentThread();
  SetThreadAffinityMask(thisthread, 0x02); // Set Thread in Core
  SetThreadPriority(thisthread,THREAD_PRIORITY_HIGHEST);
  timeV=GetTime();
  test();
  timeV=GetTime()-timeV;
  printf("Time:%lX\n",(unsigned long)timeV);
}
--
※ 發信站: 批踢踢實業坊(ptt.cc) 
◆ From: 61.225.155.103
推
10/11 16:30, , 1F
10/11 16:30, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 3 篇):
ASM 近期熱門文章
PTT數位生活區 即時熱門文章