diff options
author | Torne Wuff <torne@wolfpuppy.org.uk> | 2010-04-01 16:27:21 +0000 |
---|---|---|
committer | Torne Wuff <torne@wolfpuppy.org.uk> | 2010-04-01 16:27:21 +0000 |
commit | 52e528e057d7fd8d55116edf40500e0c0b3b75e8 (patch) | |
tree | 651413bf0f31fc64baeef8b4063c697d5df07baa | |
parent | f376fd2f4aa9b27f2a6299177b4cc3c014da01f3 (diff) | |
download | rockbox-52e528e057d7fd8d55116edf40500e0c0b3b75e8.tar.gz rockbox-52e528e057d7fd8d55116edf40500e0c0b3b75e8.zip |
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
-rw-r--r-- | apps/gui/theme_settings.c | 3 | ||||
-rw-r--r-- | apps/main.c | 48 | ||||
-rw-r--r-- | apps/settings.c | 28 | ||||
-rw-r--r-- | firmware/export/bootchart.h | 42 | ||||
-rwxr-xr-x | tools/configure | 15 |
5 files changed, 132 insertions, 4 deletions
diff --git a/apps/gui/theme_settings.c b/apps/gui/theme_settings.c index 4ab18b53fe..086dff5385 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("<skin load ", skins[i].suffix); } viewportmanager_theme_changed(THEME_STATUSBAR); #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 diff --git a/apps/main.c b/apps/main.c index 7c43c0c277..487848caaf 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("<init"); FOR_NB_SCREENS(i) { screens[i].clear_display(); @@ -167,6 +170,7 @@ int main(void) global_status.last_volume_change = 0; /* no calls INIT_ATTR functions after this point anymore! * see definition of INIT_ATTR in config.h */ + 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("<show_logo"); lang_init(core_language_builtin, language_strings, LANG_LAST_INDEX_IN_ARRAY); @@ -436,7 +445,9 @@ static void init(void) rtc_init(); #endif #ifdef HAVE_RTC_RAM + CHART(">settings_load(RTC)"); settings_load(SETTINGS_RTC); /* early load parts of global_settings */ + CHART("<settings_load(RTC)"); #endif adc_init(); @@ -460,10 +471,18 @@ static void init(void) /* Keep the order of this 3 (viewportmanager handles statusbars) * Must be done before any code uses the multi-screen API */ + CHART(">gui_syncstatusbar_init"); gui_syncstatusbar_init(&statusbars); + CHART("<gui_syncstatusbar_init"); + CHART(">sb_skin_init"); sb_skin_init(); + CHART("<sb_skin_init"); + CHART(">gui_sync_wps_init"); gui_sync_wps_init(); + CHART("<gui_sync_wps_init"); + CHART(">viewportmanager_init"); viewportmanager_init(); + CHART("<viewportmanager_init"); #if CONFIG_CHARGING && (CONFIG_CPU == SH7034) /* charger_inserted() can't be used here because power_thread() @@ -483,7 +502,9 @@ static void init(void) } #endif + CHART(">storage_init"); rc = storage_init(); + CHART("<storage_init"); if(rc) { #ifdef HAVE_LCD_BITMAP @@ -498,7 +519,9 @@ static void init(void) } #ifdef HAVE_EEPROM_SETTINGS + CHART(">eeprom_settings_init"); eeprom_settings_init(); + CHART("<eeprom_settings_init"); #endif #ifndef HAVE_USBSTACK @@ -527,7 +550,9 @@ static void init(void) if (!mounted) { + CHART(">disk_mount_all"); rc = disk_mount_all(); + CHART("<disk_mount_all"); if (rc<=0) { lcd_clear_display(); @@ -561,19 +586,32 @@ static void init(void) } else #endif + { + CHART(">settings_load(ALL)"); settings_load(SETTINGS_ALL); + CHART("<settings_load(ALL)"); + } - if (init_dircache(true) < 0) + CHART(">init_dircache(true)"); + rc = init_dircache(true); + CHART("<init_dircache(true"); + if (rc < 0) { #ifdef HAVE_TAGCACHE remove(TAGCACHE_STATEFILE); #endif } + CHART(">settings_apply(true)"); settings_apply(true); + CHART("<settings_apply(true)"); + CHART(">init_dircache(false)"); init_dircache(false); + CHART("<init_dircache(false)"); #ifdef HAVE_TAGCACHE + CHART(">init_tagcache"); init_tagcache(); + CHART("<init_tagcache"); #endif #ifdef HAVE_EEPROM_SETTINGS @@ -581,7 +619,9 @@ static void init(void) { /* In case we crash. */ firmware_settings.disk_clean = false; + CHART(">eeprom_settings_store"); eeprom_settings_store(); + CHART("<eeprom_settings_store"); } #endif playlist_init(); @@ -614,7 +654,9 @@ static void init(void) talk_init(); #endif /* CONFIG_CODEC != SWCODEC */ + CHART(">audio_init"); audio_init(); + CHART("<audio_init"); #if (CONFIG_CODEC == SWCODEC) && defined(HAVE_RECORDING) && !defined(SIMULATOR) pcm_rec_init(); @@ -636,9 +678,13 @@ static void init(void) lineout_set(global_settings.lineout_active); #endif #ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN + CHART("<check_bootfile(false)"); check_bootfile(false); /* remember write time and filesize */ + CHART(">check_bootfile(false)"); #endif + CHART("<settings_apply_skins"); settings_apply_skins(); + CHART(">settings_apply_skins"); } #ifdef CPU_PP diff --git a/apps/settings.c b/apps/settings.c index 412bedc464..d5fd98e70a 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 ", global_settings.font_file); + if (rc < 0) font_reset(NULL); } else @@ -851,7 +856,10 @@ void settings_apply(bool read_disk) && global_settings.remote_font_file[0] != '-') { snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", global_settings.remote_font_file); - if (font_load_remoteui(buf) < 0) + CHART2(">font_load_remoteui ", global_settings.remote_font_file); + rc = font_load_remoteui(buf); + CHART2("<font_load_remoteui ", global_settings.remote_font_file); + if (rc < 0) font_load_remoteui(NULL); } else @@ -860,7 +868,9 @@ void settings_apply(bool read_disk) if ( global_settings.kbd_file[0]) { snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd", global_settings.kbd_file); + CHART(">load_kbd"); load_kbd(buf); + CHART("<load_kbd"); } else load_kbd(NULL); @@ -869,16 +879,26 @@ void settings_apply(bool read_disk) if ( global_settings.lang_file[0]) { snprintf(buf, sizeof buf, LANG_DIR "/%s.lng", global_settings.lang_file); + CHART(">lang_core_load"); lang_core_load(buf); + CHART("<lang_core_load"); + CHART(">talk_init"); talk_init(); /* use voice of same language */ + CHART("<talk_init"); } /* load the icon set */ + CHART(">icons_init"); icons_init(); + CHART("<icons_init"); #ifdef HAVE_LCD_COLOR if (global_settings.colors_file[0]) + { + CHART(">read_color_theme_file"); read_color_theme_file(); + CHART("<read_color_theme_file"); + } #endif } #ifdef HAVE_LCD_COLOR @@ -901,7 +921,9 @@ void settings_apply(bool read_disk) lcd_scroll_delay(global_settings.scroll_delay); + CHART(">set_codepage"); set_codepage(global_settings.default_codepage); + CHART("<set_codepage"); #if CONFIG_CODEC == SWCODEC #ifdef HAVE_CROSSFADE @@ -966,7 +988,9 @@ void settings_apply(bool read_disk) #endif #ifdef HAVE_LCD_BITMAP /* already called with THEME_STATUSBAR in settings_apply_skins() */ + CHART(">viewportmanager_theme_changed"); viewportmanager_theme_changed(THEME_UI_VIEWPORT|THEME_LANGUAGE|THEME_BUTTONBAR); + CHART("<viewportmanager_theme_changed"); #endif } diff --git a/firmware/export/bootchart.h b/firmware/export/bootchart.h new file mode 100644 index 0000000000..cad41ee50c --- /dev/null +++ b/firmware/export/bootchart.h @@ -0,0 +1,42 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * 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 <config.h> +#include <stdbool.h> +#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 9a98bff550..628e7d5877 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@ |