From 52e528e057d7fd8d55116edf40500e0c0b3b75e8 Mon Sep 17 00:00:00 2001 From: Torne Wuff Date: Thu, 1 Apr 2010 16:27:21 +0000 Subject: Boot charting support. Select (B)ootchart in advanced options in configure, and logf will record timings for various stages of boot, for performance comparisons. Format logged is: BC:>function_name,123,80 where 123 is the line number, 80 is the number of ticks since boot. This can be loaded as CSV into a spreadsheet. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25426 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/theme_settings.c | 3 +++ apps/main.c | 48 ++++++++++++++++++++++++++++++++++++++++++++- apps/settings.c | 28 ++++++++++++++++++++++++-- firmware/export/bootchart.h | 42 +++++++++++++++++++++++++++++++++++++++ tools/configure | 15 +++++++++++++- 5 files changed, 132 insertions(+), 4 deletions(-) create mode 100644 firmware/export/bootchart.h diff --git a/apps/gui/theme_settings.c b/apps/gui/theme_settings.c index 4ab18b5..086dff5 100644 --- a/apps/gui/theme_settings.c +++ b/apps/gui/theme_settings.c @@ -33,6 +33,7 @@ #include "skin_engine/skin_engine.h" #include "skin_engine/skin_fonts.h" #include "statusbar-skinned.h" +#include "bootchart.h" /* call this after loading a .wps/.rwps or other skin files, so that the @@ -73,6 +74,7 @@ void settings_apply_skins(void) #ifdef HAVE_REMOTE_LCD screen = skins[i].suffix[0] == 'r' ? SCREEN_REMOTE : SCREEN_MAIN; #endif + CHART2(">skin load ", skins[i].suffix); if (skins[i].setting[0] && skins[i].setting[0] != '-') { snprintf(buf, sizeof buf, WPS_DIR "/%s.%s", @@ -83,6 +85,7 @@ void settings_apply_skins(void) { skins[i].loadfunc(screen, NULL, true); } + CHART2(" 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 diff --git a/apps/main.c b/apps/main.c index 7c43c0c..487848c 100644 --- a/apps/main.c +++ b/apps/main.c @@ -75,6 +75,7 @@ #include "icon.h" #include "viewport.h" #include "statusbar-skinned.h" +#include "bootchart.h" #ifdef IPOD_ACCESSORY_PROTOCOL #include "iap.h" @@ -136,7 +137,9 @@ int main(void) #endif { int i; + CHART(">init"); init(); + CHART("root_menu"); root_menu(); } @@ -414,13 +418,18 @@ static void init(void) #ifdef CPU_ARM enable_fiq(); #endif + /* current_tick should be ticking by now */ + CHART("ticking"); + lcd_init(); #ifdef HAVE_REMOTE_LCD lcd_remote_init(); #endif font_init(); + CHART(">show_logo"); show_logo(); + CHART("settings_load(RTC)"); settings_load(SETTINGS_RTC); /* early load parts of global_settings */ + CHART("gui_syncstatusbar_init"); gui_syncstatusbar_init(&statusbars); + CHART("sb_skin_init"); sb_skin_init(); + CHART("gui_sync_wps_init"); gui_sync_wps_init(); + CHART("viewportmanager_init"); viewportmanager_init(); + CHART("storage_init"); rc = storage_init(); + CHART("eeprom_settings_init"); eeprom_settings_init(); + CHART("disk_mount_all"); rc = disk_mount_all(); + CHART("settings_load(ALL)"); settings_load(SETTINGS_ALL); + CHART("init_dircache(true)"); + rc = init_dircache(true); + CHART("settings_apply(true)"); settings_apply(true); + CHART("init_dircache(false)"); init_dircache(false); + CHART("init_tagcache"); init_tagcache(); + CHART("eeprom_settings_store"); eeprom_settings_store(); + CHART("audio_init"); audio_init(); + CHART("check_bootfile(false)"); #endif + CHART("settings_apply_skins"); } #ifdef CPU_PP diff --git a/apps/settings.c b/apps/settings.c index 412bedc..d5fd98e 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -70,6 +70,7 @@ #include "skin_engine/skin_engine.h" #include "viewport.h" #include "statusbar-skinned.h" +#include "bootchart.h" #if CONFIG_CODEC == MAS3507D void dac_line_in(bool enable); @@ -745,6 +746,7 @@ void settings_apply(bool read_disk) { char buf[64]; + int rc; #if CONFIG_CODEC == SWCODEC int i; #endif @@ -841,7 +843,10 @@ void settings_apply(bool read_disk) && global_settings.font_file[0] != '-') { snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", global_settings.font_file); - if (font_load(NULL, buf) < 0) + CHART2(">font_load ", global_settings.font_file); + rc = font_load(NULL, buf); + CHART2("font_load_remoteui ", global_settings.remote_font_file); + rc = font_load_remoteui(buf); + CHART2("load_kbd"); load_kbd(buf); + CHART("lang_core_load"); lang_core_load(buf); + CHART("talk_init"); talk_init(); /* use voice of same language */ + CHART("icons_init"); icons_init(); + CHART("read_color_theme_file"); read_color_theme_file(); + CHART("set_codepage"); set_codepage(global_settings.default_codepage); + CHART("viewportmanager_theme_changed"); viewportmanager_theme_changed(THEME_UI_VIEWPORT|THEME_LANGUAGE|THEME_BUTTONBAR); + CHART(" ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 by Torne Wuff + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef BOOTCHART_H +#define BOOTCHART_H +#include +#include +#include "../include/_ansi.h" +#include "logf.h" +#include "kernel.h" + +#ifdef DO_BOOTCHART + +/* we call _logf directly to avoid needing LOGF_ENABLE per-file */ +#define CHART2(x,y) _logf("BC:%s%s,%d,%ld", (x), (y), __LINE__, current_tick) +#define CHART(x) CHART2(x,"") + +#else /* !DO_BOOTCHART */ + +#define CHART2(x,y) +#define CHART(x) + +#endif /* DO_BOOTCHART */ + +#endif /* BOOTCHART_H */ diff --git a/tools/configure b/tools/configure index 9a98bff..628e7d5 100755 --- a/tools/configure +++ b/tools/configure @@ -12,6 +12,7 @@ CCOPTS="-W -Wall -Wundef -O -nostdlib -ffreestanding -Wstrict-prototypes -pipe" use_logf="#undef ROCKBOX_HAS_LOGF" +use_bootchart="#undef DO_BOOTCHART" scriptver=`echo '$Revision$' | sed -e 's:\\$::g' -e 's/Revision: //'` @@ -366,7 +367,7 @@ whichadvanced () { interact=1 echo "" echo "Enter your developer options (press enter when done)" - printf "(D)EBUG, (L)ogf, (S)imulator, (P)rofiling, (V)oice, (W)in32 crosscompile" + printf "(D)EBUG, (L)ogf, (B)ootchart, (S)imulator, (P)rofiling, (V)oice, (W)in32 crosscompile" if [ "$memory" = "2" ]; then printf ", (8)MB MOD" fi @@ -407,6 +408,11 @@ whichadvanced () { echo "logf() support enabled" logf="yes" ;; + [Bb]) + echo "bootchart enabled (logf also enabled)" + bootchart="yes" + logf="yes" + ;; [Ss]) echo "Simulator build enabled" simulator="yes" @@ -493,6 +499,9 @@ whichadvanced () { if [ "yes" = "$logf" ]; then use_logf="#define ROCKBOX_HAS_LOGF 1" fi + if [ "yes" = "$bootchart" ]; then + use_bootchart="#define DO_BOOTCHART 1" + fi if [ "yes" = "$simulator" ]; then debug="-DDEBUG" extradefines="$extradefines -DSIMULATOR" @@ -2904,6 +2913,7 @@ fi sed > autoconf.h \ -e "s,@ENDIAN@,${defendian},g" \ -e "s,^#undef ROCKBOX_HAS_LOGF,$use_logf,g" \ + -e "s,^#undef DO_BOOTCHART,$use_bootchart,g" \ -e "s,@config_rtc@,$config_rtc,g" \ -e "s,@have_rtc_alarm@,$have_rtc_alarm,g" \ -e "s,@RBDIR@,${rbdir},g" \ @@ -2921,6 +2931,9 @@ sed > autoconf.h \ /* Define this if you build rockbox to support the logf logging and display */ #undef ROCKBOX_HAS_LOGF +/* Define this to record a chart with timings for the stages of boot */ +#undef DO_BOOTCHART + /* optional define for a backlight modded Ondio */ @have_backlight@ -- cgit v1.1