3
* Copyright (c) 2005 Sandro Giessl <sandro@giessl.com>
4
* Copyright (c) 2005 Luciano Montanaro <mikelima@cirulla.net>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
#include <kdecoration_plugins_p.h>
26
#include <kdecorationfactory.h>
29
#include <sys/timeb.h>
33
#include <kaboutdata.h>
34
#include <kapplication.h>
35
#include <kcmdlineargs.h>
40
DecoBenchApplication::DecoBenchApplication(const QString &library, Tests tests, int count) :
44
KConfig kwinConfig("kwinrc");
45
kwinConfig.setGroup("Style");
47
plugins = new KDecorationPreviewPlugins( &kwinConfig );
48
preview = new KDecorationPreview( plugins, 0 );
50
if (plugins->loadPlugin(library) )
51
kDebug() << "Decoration library " << library << " loaded...";
53
kError() << "Error loading decoration library " << library << "!" << endl;
55
if (preview->recreateDecoration() )
56
kDebug() << "Decoration created...";
58
kError() << "Error creating decoration!" << endl;
63
DecoBenchApplication::~DecoBenchApplication()
69
void DecoBenchApplication::executeTest()
71
clock_t stime = clock();
75
if (m_tests == AllTests || m_tests == RepaintTest)
76
preview->performRepaintTest(m_count);
77
if (m_tests == AllTests || m_tests == CaptionTest)
78
preview->performCaptionTest(m_count);
79
if (m_tests == AllTests || m_tests == ResizeTest)
80
preview->performResizeTest(m_count);
81
if (m_tests == AllTests || m_tests == RecreationTest)
82
preview->performRecreationTest(m_count);
84
clock_t etime = clock();
87
long long time_diff = (aend.time - astart.time)*1000+aend.millitm - astart.millitm;
88
kDebug() << "Total:" << (float(time_diff)/1000);
92
int main(int argc, char** argv)
94
QString style = "keramik";
95
// KApplication app(argc, argv);
96
KAboutData about("decobenchmark", 0, ki18n("DecoBenchmark"), "0.1", ki18n("kwin decoration performance tester..."), KAboutData::License_LGPL, ki18n("(C) 2005 Sandro Giessl"));
97
KCmdLineArgs::init(argc, argv, &about);
99
KCmdLineOptions options;
100
options.add("+decoration", ki18n("Decoration library to use, such as kwin3_plastik."));
101
options.add("+tests", ki18n("Which test should be executed ('all', 'repaint', 'caption', 'resize', 'recreation')"));
102
options.add("+repetitions", ki18n("Number of test repetitions."));
103
KCmdLineArgs::addCmdLineOptions( options );
105
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
107
if (args->count() != 3)
108
KCmdLineArgs::usage("Wrong number of arguments!");
110
QString library = QString(args->arg(0) );
111
QString t = QString(args->arg(1) );
112
int count = QString(args->arg(2) ).toInt();
117
else if (t == "repaint")
119
else if (t == "caption")
121
else if (t == "resize")
123
else if (t == "recreation")
124
test = RecreationTest;
126
KCmdLineArgs::usage("Specify a valid test!");
128
DecoBenchApplication app(library, test, count);
130
QTimer::singleShot(0, &app, SLOT(executeTest()));
135
// kate: space-indent off; tab-width 4;