Reduce the number of getParent() function calls for print operations

This commit is contained in:
Markus Gans 2015-10-14 04:06:26 +02:00
parent 70f5b545a5
commit 62890f6ecc
9 changed files with 80 additions and 25 deletions

View File

@ -1,3 +1,6 @@
2015-10-13 Markus Gans <guru.mail@muenster.de>
* Reduce the number of getParent() function calls for print operations
2015-10-11 Markus Gans <guru.mail@muenster.de>
* Improve attribute setting for bold, reverse and underline output
* Better support for monochrom terminals

View File

@ -4,25 +4,39 @@
PREFIX="/usr"
case "$1" in
"--help"|"help")
echo "Usage: $0 {help|debug|fulldebug|profile|gcov|release}"
exit 1
;;
"--debug"|"debug")
./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -pedantic"
;;
"--fulldebug"|"fulldebug")
./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -Weffc++ -pedantic -pedantic-errors -Wextra -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpadded -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstack-protector -Wstrict-aliasing -Wstrict-aliasing=2 -Wswitch -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wsign-promo -Woverloaded-virtual -Wstrict-null-sentinel -fext-numeric-literals -Wreorder -Wnoexcept -Wnarrowing -Wliteral-suffix -Wctor-dtor-privacy"
;;
"--profile"|"profile")
./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-pg -O0 -DDEBUG -W -Wall -pedantic"
./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -pg -O0 -DDEBUG -W -Wall -pedantic"
;;
"--gcov"|"gcov")
./configure --prefix="$PREFIX" CXXFLAGS="-fprofile-arcs -ftest-coverage"
;;
"--release"|"release"|*)
"--release"|"release")
./configure --prefix="$PREFIX"
;;
"--help"|"help"|*)
echo "Usage:"
echo " $(basename "$0") {COMMAND}"
echo ""
echo "Commands:"
echo " help Show this help"
echo " debug Compile with debug option"
echo " fulldebug Compile with all warning options"
echo " profile Compile with profile option (analysis with gprof)"
echo " gcov Compile with options for coverage analysis with gcov"
echo " release Compile for release"
exit 1
;;
esac
make V=1 -j10

View File

@ -1,5 +1,5 @@
#!/bin/bash
LD_PRELOAD="/usr/lib64/libprofiler.so.0" CPUPROFILE=../text/ui.prof ../test/ui
pprof --gv ../test/ui ../test/ui.prof
LD_LIBRARY_PATH=../src/.libs/ LD_PRELOAD="/usr/lib64/libprofiler.so.0" CPUPROFILE=../test/.libs/ui.prof ../test/.libs/ui
pprof --gv ../test/.libs/ui ../test/.libs/ui.prof

6
scripts/kcachegrind.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
LD_LIBRARY_PATH=../src/.libs/ valgrind --tool=callgrind -v ../test/.libs/ui 2>/dev/null
kcachegrind
rm -f callgrind.out.*

View File

@ -4,7 +4,7 @@
PROG="ui"
ltrace -o ./$PROG.ltrace ../test/.libs/$PROG
LD_LIBRARY_PATH=../src/.libs/ ltrace -o ./$PROG.ltrace ../test/.libs/$PROG
less ./$PROG.ltrace
rm -f ./$PROG.ltrace
rm -f ./$PROG.ltrace ./gmon.out

View File

@ -1,12 +1,11 @@
#!/bin/bash
DIR="$PWD"
cd ../src
make clean
make profile
./finalcut
gprof ./finalcut >./profile.txt
cd ../test/.libs/
LD_LIBRARY_PATH=../../src/.libs/ ./ui
gprof ./ui >./profile.txt
rm ./gmon.out
less ./profile.txt
rm ./profile.txt
cd "$DIR"

View File

@ -3804,14 +3804,12 @@ int FTerm::print (FString& s)
term_area* area;
FWidget* w;
w = static_cast<FWidget*>(this);
FWidget* area_widget = FWindow::getWindowWidget(w);
area = w->getPrintArea();
if ( area_widget && area_widget->getVWin() )
area = area_widget->getVWin();
else
if ( ! area )
{
FWidget* area_widget = w->getRootWidget();
area = vdesktop;
area_widget = w->getRootWidget();
if ( ! area_widget )
return -1;
}
@ -3934,14 +3932,12 @@ int FTerm::print (register int c)
term_area* area;
FWidget* w;
w = static_cast<FWidget*>(this);
FWidget* area_widget = FWindow::getWindowWidget(w);
area = w->getPrintArea();
if ( area_widget )
area = area_widget->getVWin();
else
if ( ! area )
{
FWidget* area_widget = w->getRootWidget();
area = vdesktop;
area_widget = w->getRootWidget();
if ( ! area_widget )
return -1;
}

View File

@ -68,6 +68,7 @@ FWidget::FWidget (FWidget* parent)
, adjustWidgetSize(1,1,1,1)
, adjustWidgetSizeGlobal(1,1,1,1)
, statusbar_message()
, print_area(0)
{
resize_term = false;
@ -359,6 +360,38 @@ void FWidget::setColorTheme()
}
}
//----------------------------------------------------------------------
FTerm::term_area* FWidget::getPrintArea()
{
if ( print_area )
return print_area;
else
{
FWidget* area_widget = FWindow::getWindowWidget(this);
if ( area_widget )
{
term_area* area = area_widget->getVWin();
if ( area )
{
print_area = area;
return area;
}
else
return 0;
}
else
return 0;
}
}
//----------------------------------------------------------------------
void FWidget::setPrintArea(term_area* area)
{
print_area = area;
}
// protected methods of FWidget
//----------------------------------------------------------------------
void FWidget::adjustSize()

View File

@ -277,6 +277,8 @@ class FWidget : public FObject, public FTerm
static FMenuBar* menubar;
static FWidget* show_root_widget;
static FWidget* redraw_root_widget;
term_area* print_area;
friend class FTerm;
friend class FApplication;
friend class FToggleButton;
@ -288,6 +290,8 @@ class FWidget : public FObject, public FTerm
void processDestroy();
virtual void draw();
static void setColorTheme();
term_area* getPrintArea();
void setPrintArea(term_area*);
protected:
virtual void adjustSize();