View Single Post
Old 14 December 2013, 21:56   #1
Registered User
Join Date: Aug 2004
Posts: 2,828
Profiling WinUAE with Visual Studio 2013

I've been playing/experimenting with the profiling facility in Visual Studio 2013.

In my Windows 7 VirtualBox VM I couldn't get the sampling method to work; no samples are captured. Am I doing something wrong or is VirtualBox incompatible with Visual Studio sampling? [With sampling, Visual Studio would periodically check which function is being run. Over time it builds up a statistical picture of the functions which use most CPU time.]

The instrumentation profiling method did work. With that method, a special version of the executable is built, which allows all function calls (and the time taken for each) to be recorded and analysed. However that logging adds a significant amount of overhead to the program.

On starting the instrumented winuae.exe, it takes ages (like about 10 minutes) until the settings window appears. While that isn't a big issue for the normal winuae.exe, maybe this has shown up something which could improve startup time slightly.

The profiling results showed a huge number of calls to free() in this code path:
default_prefs() ⇒ inputdevice_default_prefs() ⇒ inputdevice_default_kb_all() ⇒ set_kbr_default() ⇒ clear_id() ⇒ xfree()

Take a look at clear_id():
static void clear_id (struct uae_input_device *id)
#ifndef	_DEBUG
	int i, j;
	for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
		for (j = 0; j < MAX_INPUT_SUB_EVENT_ALL; j++)
			xfree (id->custom[i][j]);
	TCHAR *cn = id->configname;
	TCHAR *n = id->name;
	memset (id, 0, sizeof (struct uae_input_device));
	id->configname = cn;
	id->name = n;
To reduce the number of function calls you could change it to only call xfree() when the argument is non-zero. But look at the loop in set_kbr_default() which calls clear_id():
	for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
		clear_id (kbr);
		kbr->extra[i] = -1;
and compare with the for loop in clear_id() itself. Are you doing a lot of unnecessary free()ing with the two nested for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++)???
mark_k is offline  
AdSense AdSense  
Page generated in 0.16106 seconds with 9 queries