Created
February 19, 2011 22:08
-
-
Save jonforums/835420 to your computer and use it in GitHub Desktop.
VTune instrumented mini-app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* build with: | |
* cl /Zi /Oy- slowhello.c user32.lib | |
* -or- | |
* gcc -g -o slowhello.exe slowhello.c -luser32 | |
* | |
* -or to profile with VTune- | |
* rename libittnotify.lib to libittnotify.a | |
* gcc -Wall -DVTUNE_BUILD -ggdb3 -O0 | |
* -Ic:/devlibs/vtune/include -Lc:/devlibs/vtune/lib32 | |
* -o slowhello.exe slowhello.c -luser32 -littnotify | |
*/ | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <windows.h> | |
#ifndef VTUNE_BUILD | |
# define INTEL_NO_ITTNOTIFY_API | |
#endif | |
#include "ittnotify.h" | |
__itt_event _slow_event; | |
__itt_frame _stat_frame_id; | |
#define NAP_TIME 2000 | |
#define STAT_COUNT 50000 | |
void rb_win_io(void) | |
{ | |
#if 0 | |
Sleep(NAP_TIME); | |
#endif | |
int i, rc; | |
struct _stat buf; | |
char *filename = "slowhello.exe"; | |
for (i = 0; i < STAT_COUNT; i++) | |
{ | |
__itt_frame_begin(_stat_frame_id); | |
rc = _stat(filename, &buf); | |
__itt_frame_end(_stat_frame_id); | |
} | |
} | |
void hello(void) | |
{ | |
_stat_frame_id = __itt_frame_create("Stat Domain"); | |
_slow_event = __itt_event_create("Slow Mark", 9); | |
if (_slow_event == 0) return; | |
int rv = __itt_event_start(_slow_event); | |
if (rv != 0) return; | |
rb_win_io(); | |
rv = __itt_event_end(_slow_event); | |
if (rv != 0) return; | |
MessageBox(NULL, | |
TEXT("Hello World!"), | |
TEXT("Alert"), | |
MB_SETFOREGROUND); | |
} | |
void main(void) | |
{ | |
hello(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment