From a9ea644c5c0b51d4ab4f16d478af3c9466ef079e Mon Sep 17 00:00:00 2001 From: Stanislav Shwartsman Date: Tue, 20 Nov 2007 18:36:26 +0000 Subject: [PATCH] Print timestamps feature for performance measurements If enabled (in .bochsrc) + --enable-show-ips=1 Bochs will print IPS + time data every second --- bochs/bochs.h | 3 ++- bochs/config.cc | 16 +++++++++++++++- bochs/main.cc | 8 +++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/bochs/bochs.h b/bochs/bochs.h index f9dbc3d97..9372bb305 100644 --- a/bochs/bochs.h +++ b/bochs/bochs.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: bochs.h,v 1.214 2007-11-01 18:03:48 sshwarts Exp $ +// $Id: bochs.h,v 1.215 2007-11-20 18:36:26 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -443,6 +443,7 @@ typedef struct { bx_bool unsupported_io; bx_bool serial; bx_bool cdrom; + bx_bool print_timestamps; #if BX_MAGIC_BREAKPOINT bx_bool magic_break_enabled; #endif diff --git a/bochs/config.cc b/bochs/config.cc index d849b1325..8c17d1331 100755 --- a/bochs/config.cc +++ b/bochs/config.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: config.cc,v 1.123 2007-10-24 23:27:39 sshwarts Exp $ +// $Id: config.cc,v 1.124 2007-11-20 18:36:26 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -2837,6 +2837,20 @@ static Bit32s parse_line_formatted(const char *context, int num_params, char *pa } } #endif + else if (!strcmp(params[0], "print_timestamps")) { + if (num_params != 2) { + PARSE_ERR(("%s: print_timestamps directive: wrong # args.", context)); + } + if (strncmp(params[1], "enabled=", 8)) { + PARSE_ERR(("%s: print_timestamps directive malformed.", context)); + } + if (params[1][8] == '0' || params[1][8] == '1') { + bx_dbg.print_timestamps = params[1][8] - '0'; + } + else { + PARSE_ERR(("%s: print_timestamps directive malformed.", context)); + } + } else if (!strcmp(params[0], "ne2k")) { int tmp[6]; char tmpchar[6]; diff --git a/bochs/main.cc b/bochs/main.cc index 4bcfc74b0..5b8c26a91 100644 --- a/bochs/main.cc +++ b/bochs/main.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: main.cc,v 1.367 2007-11-18 21:09:09 sshwarts Exp $ +// $Id: main.cc,v 1.368 2007-11-20 18:36:26 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -1234,8 +1234,10 @@ void bx_signal_handler(int signum) bx_gui->show_ips((Bit32u) ips_count); ticks_count = bx_pc_system.time_ticks(); counts++; -// printf("MIPS: %u\tticks/counts = %u\t\t(%us)\n", -// (unsigned) ips_count, (unsigned) (ticks_count/counts), (unsigned) counts); + if (bx_dbg.print_timestamps) { + printf("IPS: %u\taverage = %u\t\t(%us)\n", + (unsigned) ips_count, (unsigned) (ticks_count/counts), (unsigned) counts); + } } #if !defined(__MINGW32__) && !defined(_MSC_VER) signal(SIGALRM, bx_signal_handler);