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.
27 #include <kdecoration_plugins_p.h>
28 #include <kdecorationfactory.h>
31 #include <sys/timeb.h>
35 #include <kaboutdata.h>
36 #include <kapplication.h>
37 #include <kcmdlineargs.h>
41 DecoBenchApplication::DecoBenchApplication(const QString
&library
, Tests tests
, int count
) :
45 KConfig
kwinConfig("kwinrc");
46 kwinConfig
.setGroup("Style");
48 plugins
= new KDecorationPreviewPlugins( &kwinConfig
);
49 preview
= new KDecorationPreview( plugins
, 0 );
51 if (plugins
->loadPlugin(library
) )
52 kDebug(1212) << "Decoration library " << library
<< " loaded...";
54 kError(1212) << "Error loading decoration library " << library
<< "!" << endl
;
56 if (preview
->recreateDecoration() )
57 kDebug(1212) << "Decoration created...";
59 kError(1212) << "Error creating decoration!" << endl
;
64 DecoBenchApplication::~DecoBenchApplication()
70 void DecoBenchApplication::executeTest()
72 clock_t stime
= clock();
76 if (m_tests
== AllTests
|| m_tests
== RepaintTest
)
77 preview
->performRepaintTest(m_count
);
78 if (m_tests
== AllTests
|| m_tests
== CaptionTest
)
79 preview
->performCaptionTest(m_count
);
80 if (m_tests
== AllTests
|| m_tests
== ResizeTest
)
81 preview
->performResizeTest(m_count
);
82 if (m_tests
== AllTests
|| m_tests
== RecreationTest
)
83 preview
->performRecreationTest(m_count
);
85 clock_t etime
= clock();
88 long long time_diff
= (aend
.time
- astart
.time
)*1000+aend
.millitm
- astart
.millitm
;
89 kDebug(1212) << "Total:" << (float(time_diff
)/1000);
93 int main(int argc
, char** argv
)
95 QString style
= "keramik";
96 // KApplication app(argc, argv);
97 KAboutData
about("decobenchmark", 0, ki18n("DecoBenchmark"), "0.1", ki18n("kwin decoration performance tester..."), KAboutData::License_LGPL
, ki18n("(C) 2005 Sandro Giessl"));
98 KCmdLineArgs::init(argc
, argv
, &about
);
100 KCmdLineOptions options
;
101 options
.add("+decoration", ki18n("Decoration library to use, such as kwin3_plastik."));
102 options
.add("+tests", ki18n("Which test should be executed ('all', 'repaint', 'caption', 'resize', 'recreation')"));
103 options
.add("+repetitions", ki18n("Number of test repetitions."));
104 KCmdLineArgs::addCmdLineOptions( options
);
106 KCmdLineArgs
*args
= KCmdLineArgs::parsedArgs();
108 if (args
->count() != 3)
109 KCmdLineArgs::usage("Wrong number of arguments!");
111 QString library
= QString(args
->arg(0) );
112 QString t
= QString(args
->arg(1) );
113 int count
= QString(args
->arg(2) ).toInt();
118 else if (t
== "repaint")
120 else if (t
== "caption")
122 else if (t
== "resize")
124 else if (t
== "recreation")
125 test
= RecreationTest
;
127 KCmdLineArgs::usage("Specify a valid test!");
129 DecoBenchApplication
app(library
, test
, count
);
131 QTimer::singleShot(0, &app
, SLOT(executeTest()));
136 // kate: space-indent off; tab-width 4;