add caption and resize tests.
svn path=/trunk/kdebase/kwin/; revision=396655icc-effect-5.14.5
parent
b10f0059c7
commit
f80d4f2160
|
@ -39,13 +39,15 @@
|
||||||
|
|
||||||
static KCmdLineOptions options[] =
|
static KCmdLineOptions options[] =
|
||||||
{
|
{
|
||||||
{ "+[STYLE]", "Decoration to use.", "kwin3_plastik" },
|
{ "+decoration", "Decoration library to use, such as kwin3_plastik.", 0 },
|
||||||
{ "+[N]", "Number of repetitions.", "200000" },
|
{ "+tests", "Which test should be executed ('all', 'repaint', 'caption', 'resize')", 0 },
|
||||||
|
{ "+repetitions", "Number of test repetitions.", 0 },
|
||||||
{ 0, 0, 0 }
|
{ 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
DecoBenchApplication::DecoBenchApplication(const QString &library, int count) :
|
DecoBenchApplication::DecoBenchApplication(const QString &library, Tests tests, int count) :
|
||||||
m_count(count)
|
m_tests(tests),
|
||||||
|
m_count(count)
|
||||||
{
|
{
|
||||||
KConfig kwinConfig("kwinrc");
|
KConfig kwinConfig("kwinrc");
|
||||||
kwinConfig.setGroup("Style");
|
kwinConfig.setGroup("Style");
|
||||||
|
@ -67,11 +69,17 @@ DecoBenchApplication::~DecoBenchApplication()
|
||||||
|
|
||||||
void DecoBenchApplication::executeTest()
|
void DecoBenchApplication::executeTest()
|
||||||
{
|
{
|
||||||
kdDebug() << "start " << m_count << " repaints..." << endl;
|
|
||||||
clock_t stime = clock();
|
clock_t stime = clock();
|
||||||
timeb astart, aend;
|
timeb astart, aend;
|
||||||
ftime(&astart);
|
ftime(&astart);
|
||||||
preview->performRepaintTest(m_count);
|
|
||||||
|
if (m_tests == AllTests || m_tests == RepaintTest)
|
||||||
|
preview->performRepaintTest(m_count);
|
||||||
|
if (m_tests == AllTests || m_tests == CaptionTest)
|
||||||
|
preview->performCaptionTest(m_count);
|
||||||
|
if (m_tests == AllTests || m_tests == ResizeTest)
|
||||||
|
preview->performResizeTest(m_count);
|
||||||
|
|
||||||
clock_t etime = clock();
|
clock_t etime = clock();
|
||||||
ftime(&aend);
|
ftime(&aend);
|
||||||
|
|
||||||
|
@ -84,18 +92,36 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
QString style = "keramik";
|
QString style = "keramik";
|
||||||
// KApplication app(argc, argv);
|
// KApplication app(argc, argv);
|
||||||
KAboutData about("decobench", "DecoBench", "0.1", "kwin decoration performance tester...", KAboutData::License_LGPL, "(C) 2005 Sandro Giessl");
|
KAboutData about("decobenchmark", "DecoBenchmark", "0.1", "kwin decoration performance tester...", KAboutData::License_LGPL, "(C) 2005 Sandro Giessl");
|
||||||
KCmdLineArgs::init(argc, argv, &about);
|
KCmdLineArgs::init(argc, argv, &about);
|
||||||
KCmdLineArgs::addCmdLineOptions( options );
|
KCmdLineArgs::addCmdLineOptions( options );
|
||||||
|
|
||||||
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
|
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
|
||||||
|
|
||||||
QString library = QString(args->arg(0) );
|
if (args->count() != 3)
|
||||||
int count = QString(args->arg(1) ).toInt();
|
KCmdLineArgs::usage("Wrong number of arguments!");
|
||||||
|
|
||||||
DecoBenchApplication app(library, count);
|
QString library = QString(args->arg(0) );
|
||||||
|
QString t = QString(args->arg(1) );
|
||||||
|
int count = QString(args->arg(2) ).toInt();
|
||||||
|
|
||||||
|
Tests test;
|
||||||
|
if (t == "all")
|
||||||
|
test = AllTests;
|
||||||
|
else if (t == "repaint")
|
||||||
|
test = RepaintTest;
|
||||||
|
else if (t == "caption")
|
||||||
|
test = CaptionTest;
|
||||||
|
else if (t == "resize")
|
||||||
|
test = ResizeTest;
|
||||||
|
else
|
||||||
|
KCmdLineArgs::usage("Specify a valid test!");
|
||||||
|
|
||||||
|
DecoBenchApplication app(library, test, count);
|
||||||
|
|
||||||
QTimer::singleShot(0, &app, SLOT(executeTest()));
|
QTimer::singleShot(0, &app, SLOT(executeTest()));
|
||||||
app.exec();
|
app.exec();
|
||||||
}
|
}
|
||||||
#include "main.moc"
|
#include "main.moc"
|
||||||
|
|
||||||
|
// kate: space-indent off; tab-width 4;
|
||||||
|
|
|
@ -21,11 +21,18 @@
|
||||||
#ifndef BENCH_MAIN_H
|
#ifndef BENCH_MAIN_H
|
||||||
#define BENCH_MAIN_H
|
#define BENCH_MAIN_H
|
||||||
|
|
||||||
|
enum Tests {
|
||||||
|
AllTests,
|
||||||
|
RepaintTest,
|
||||||
|
CaptionTest,
|
||||||
|
ResizeTest
|
||||||
|
};
|
||||||
|
|
||||||
class DecoBenchApplication : public KApplication
|
class DecoBenchApplication : public KApplication
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DecoBenchApplication(const QString &library, int count);
|
DecoBenchApplication(const QString &library, Tests tests, int count);
|
||||||
~DecoBenchApplication();
|
~DecoBenchApplication();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -34,7 +41,10 @@ public slots:
|
||||||
private:
|
private:
|
||||||
KDecorationPreview *preview;
|
KDecorationPreview *preview;
|
||||||
KDecorationPlugins *plugins;
|
KDecorationPlugins *plugins;
|
||||||
|
Tests m_tests;
|
||||||
int m_count;
|
int m_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BENCH_MAIN_H
|
#endif // BENCH_MAIN_H
|
||||||
|
|
||||||
|
// kate: space-indent off; tab-width 4;
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include "preview.h"
|
#include "preview.h"
|
||||||
|
|
||||||
|
#include <kdebug.h>
|
||||||
|
|
||||||
#include <kapplication.h>
|
#include <kapplication.h>
|
||||||
#include <klocale.h>
|
#include <klocale.h>
|
||||||
#include <kconfig.h>
|
#include <kconfig.h>
|
||||||
|
@ -40,7 +42,7 @@ KDecorationPreview::KDecorationPreview( QWidget* parent, const char* name )
|
||||||
{
|
{
|
||||||
options = new KDecorationPreviewOptions;
|
options = new KDecorationPreviewOptions;
|
||||||
|
|
||||||
bridge = new KDecorationPreviewBridge( this, true );
|
bridge = new KDecorationPreviewBridge( this, true, "Deco Benchmark" );
|
||||||
|
|
||||||
deco = 0;
|
deco = 0;
|
||||||
|
|
||||||
|
@ -58,12 +60,40 @@ KDecorationPreview::~KDecorationPreview()
|
||||||
|
|
||||||
void KDecorationPreview::performRepaintTest(int n)
|
void KDecorationPreview::performRepaintTest(int n)
|
||||||
{
|
{
|
||||||
|
kdDebug() << "start " << n << " repaints..." << endl;
|
||||||
|
bridge->setCaption("Deco Benchmark");
|
||||||
|
deco->captionChange();
|
||||||
|
positionPreviews(0);
|
||||||
for (int i = 0; i < n; ++i) {
|
for (int i = 0; i < n; ++i) {
|
||||||
deco->widget()->repaint();
|
deco->widget()->repaint();
|
||||||
kapp->processEvents();
|
kapp->processEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KDecorationPreview::performCaptionTest(int n)
|
||||||
|
{
|
||||||
|
kdDebug() << "start " << n << " caption changes..." << endl;
|
||||||
|
QString caption = "Deco Benchmark %1";
|
||||||
|
positionPreviews(0);
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
bridge->setCaption(caption.arg(i) );
|
||||||
|
deco->captionChange();
|
||||||
|
deco->widget()->repaint();
|
||||||
|
kapp->processEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KDecorationPreview::performResizeTest(int n)
|
||||||
|
{
|
||||||
|
kdDebug() << "start " << n << " resizes..." << endl;
|
||||||
|
bridge->setCaption("Deco Benchmark");
|
||||||
|
deco->captionChange();
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
positionPreviews(i % 200);
|
||||||
|
kapp->processEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool KDecorationPreview::recreateDecoration( KDecorationPlugins* plugins )
|
bool KDecorationPreview::recreateDecoration( KDecorationPlugins* plugins )
|
||||||
{
|
{
|
||||||
delete deco;
|
delete deco;
|
||||||
|
@ -79,38 +109,15 @@ bool KDecorationPreview::recreateDecoration( KDecorationPlugins* plugins )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KDecorationPreview::positionPreviews()
|
void KDecorationPreview::positionPreviews(int shrink)
|
||||||
{
|
{
|
||||||
// int titleBarHeight, leftBorder, rightBorder, xoffset,
|
|
||||||
// dummy1, dummy2, dummy3;
|
|
||||||
|
|
||||||
if ( !deco )
|
if ( !deco )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QSize size = QSize(width()-2*10, height()-2*10)/*.expandedTo(deco->minimumSize()*/;
|
QSize size = QSize(width()-2*10-shrink, height()-2*10-shrink)/*.expandedTo(deco->minimumSize()*/;
|
||||||
|
|
||||||
QRect geometry(QPoint(10, 10), size);
|
QRect geometry(QPoint(10, 10), size);
|
||||||
deco->widget()->setGeometry(geometry);
|
deco->widget()->setGeometry(geometry);
|
||||||
|
|
||||||
// // don't have more than one reference to the same dummy variable in one borders() call.
|
|
||||||
// deco[Active]->borders( dummy1, dummy2, titleBarHeight, dummy3 );
|
|
||||||
// deco[Inactive]->borders( leftBorder, rightBorder, dummy1, dummy2 );
|
|
||||||
//
|
|
||||||
// titleBarHeight = kMin( int( titleBarHeight * .9 ), 30 );
|
|
||||||
// xoffset = kMin( kMax( 10, QApplication::reverseLayout()
|
|
||||||
// ? leftBorder : rightBorder ), 30 );
|
|
||||||
//
|
|
||||||
// // Resize the active window
|
|
||||||
// size = QSize( width() - xoffset, height() - titleBarHeight )
|
|
||||||
// .expandedTo( deco[Active]->minimumSize() );
|
|
||||||
// geometry = QRect( QPoint( 0, titleBarHeight ), size );
|
|
||||||
// deco[Active]->widget()->setGeometry( QStyle::visualRect( geometry, this ) );
|
|
||||||
//
|
|
||||||
// // Resize the inactive window
|
|
||||||
// size = QSize( width() - xoffset, height() - titleBarHeight )
|
|
||||||
// .expandedTo( deco[Inactive]->minimumSize() );
|
|
||||||
// geometry = QRect( QPoint( xoffset, 0 ), size );
|
|
||||||
// deco[Inactive]->widget()->setGeometry( QStyle::visualRect( geometry, this ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KDecorationPreview::setPreviewMask( const QRegion& reg, int mode )
|
void KDecorationPreview::setPreviewMask( const QRegion& reg, int mode )
|
||||||
|
@ -153,10 +160,15 @@ QRegion KDecorationPreview::unobscuredRegion( bool active, const QRegion& r ) co
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
KDecorationPreviewBridge::KDecorationPreviewBridge( KDecorationPreview* p, bool a )
|
KDecorationPreviewBridge::KDecorationPreviewBridge( KDecorationPreview* p, bool a, const QString &c )
|
||||||
: preview( p ), active( a )
|
: preview( p ), active( a ), m_caption( c )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KDecorationPreviewBridge::setCaption(const QString &c)
|
||||||
|
{
|
||||||
|
m_caption = c;
|
||||||
|
}
|
||||||
|
|
||||||
QWidget* KDecorationPreviewBridge::initialParentWidget() const
|
QWidget* KDecorationPreviewBridge::initialParentWidget() const
|
||||||
{
|
{
|
||||||
|
@ -254,9 +266,9 @@ QIconSet KDecorationPreviewBridge::icon() const
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KDecorationPreviewBridge::caption() const
|
QString KDecorationPreviewBridge::caption() const
|
||||||
{
|
{
|
||||||
return active ? i18n( "Active Window" ) : i18n( "Inactive Window" );
|
return m_caption;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KDecorationPreviewBridge::processMousePressEvent( QMouseEvent* )
|
void KDecorationPreviewBridge::processMousePressEvent( QMouseEvent* )
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,13 +37,15 @@ class KDecorationPreview
|
||||||
virtual ~KDecorationPreview();
|
virtual ~KDecorationPreview();
|
||||||
|
|
||||||
void performRepaintTest(int n);
|
void performRepaintTest(int n);
|
||||||
|
void performCaptionTest(int n);
|
||||||
|
void performResizeTest(int n);
|
||||||
|
|
||||||
bool recreateDecoration( KDecorationPlugins* plugin );
|
bool recreateDecoration( KDecorationPlugins* plugin );
|
||||||
void setPreviewMask( const QRegion&, int );
|
void setPreviewMask( const QRegion&, int );
|
||||||
QRegion unobscuredRegion( bool, const QRegion& ) const;
|
QRegion unobscuredRegion( bool, const QRegion& ) const;
|
||||||
QRect windowGeometry( bool ) const;
|
QRect windowGeometry( bool ) const;
|
||||||
private:
|
private:
|
||||||
void positionPreviews();
|
void positionPreviews(int shrink = 0);
|
||||||
KDecorationPreviewOptions* options;
|
KDecorationPreviewOptions* options;
|
||||||
KDecorationPreviewBridge* bridge;
|
KDecorationPreviewBridge* bridge;
|
||||||
KDecoration* deco;
|
KDecoration* deco;
|
||||||
|
@ -53,7 +55,10 @@ class KDecorationPreviewBridge
|
||||||
: public KDecorationBridge
|
: public KDecorationBridge
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KDecorationPreviewBridge( KDecorationPreview* preview, bool active );
|
KDecorationPreviewBridge( KDecorationPreview* preview, bool active, const QString &caption );
|
||||||
|
|
||||||
|
void setCaption(const QString &caption);
|
||||||
|
|
||||||
virtual bool isActive() const;
|
virtual bool isActive() const;
|
||||||
virtual bool isCloseable() const;
|
virtual bool isCloseable() const;
|
||||||
virtual bool isMaximizable() const;
|
virtual bool isMaximizable() const;
|
||||||
|
@ -100,6 +105,7 @@ class KDecorationPreviewBridge
|
||||||
private:
|
private:
|
||||||
KDecorationPreview* preview;
|
KDecorationPreview* preview;
|
||||||
bool active;
|
bool active;
|
||||||
|
QString m_caption;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KDecorationPreviewOptions
|
class KDecorationPreviewOptions
|
||||||
|
|
Loading…
Reference in New Issue