fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / registry / workben / regspeed.cxx
blobcce5234c49e2af69b6502fd2db36f7f4e879e789
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <iostream>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <time.h>
25 #include <sys/timeb.h>
26 #include <sys/types.h>
28 #include "registry/registry.h"
29 #include <rtl/ustring.hxx>
30 #include <rtl/alloc.h>
32 using namespace std;
34 /*****************************************************************
35 MyTimer
36 *****************************************************************/
37 #ifndef UNX
38 class MyTimer
40 public:
41 void start() { _ftime( &m_start ); };
42 void stop()
44 _ftime( &m_stop );
45 m_diff = difftime(m_stop.time, m_start.time);
46 if (m_stop.millitm > m_start.millitm)
48 m_diff += ((double)(m_stop.millitm - m_start.millitm)) / 1000;
50 else
52 m_diff -= 1;
53 m_diff += ((double)(1000 - (m_start.millitm - m_stop.millitm))) / 1000;
55 printf(" %.4f Sekunden\n", m_diff);
58 protected:
59 struct _timeb m_start, m_stop;
60 double m_diff;
62 #else
63 extern "C" int ftime(struct timeb *pt);
65 class MyTimer
67 public:
68 void start() { ftime( &m_start ); };
69 void stop()
71 ftime( &m_stop );
72 m_diff = difftime(m_stop.time, m_start.time);
73 if (m_stop.millitm > m_start.millitm)
75 m_diff += ((double)(m_stop.millitm - m_start.millitm)) / 1000;
77 else
79 m_diff -= 1;
80 m_diff += ((double)(1000 - (m_start.millitm - m_stop.millitm))) / 1000;
82 printf(" %.4f Sekunden\n", m_diff);
85 protected:
86 struct timeb m_start, m_stop;
87 double m_diff;
89 #endif
92 #if (defined UNX)
93 int main( int argc, char * argv[] )
94 #else
95 int _cdecl main( int argc, char * argv[] )
96 #endif
98 RegHandle hReg;
99 RegKeyHandle hRootKey, hKey, hSubKey, hSubSubKey;
100 OUString sName1("regkey");
101 OUString sName2("regSubkey");
102 OUString sName3("regSubSubkey");
103 OUString keyName1;
104 OUString keyName2;
105 OUString keyName3;
106 int S1 = 10;
107 int S2 = 10;
108 int S3 = 10;
109 MyTimer aTimer;
111 if (argc < 4)
113 cerr << "using regspeed count1 count2 count3\n";
114 exit(1);
117 S1 = atoi(argv[1]);
118 S2 = atoi(argv[2]);
119 S3 = atoi(argv[3]);
121 OUString speedReg( "speed.reg");
122 if (reg_createRegistry(speedReg.pData, &hReg))
124 cout << "creating registry \"test.reg\" failed\n";
125 } else
127 if (reg_openRootKey(hReg, &hRootKey))
129 cout << "open root key \"test.reg\" failed\n";
130 } else
132 printf("\n %d keys anlegen, oeffnen und schliessen dauert ... ", (S1 * S2 * S3));
133 aTimer.start();
135 for (sal_Int32 i=0; i < S1; i++)
137 keyName1 = sName1;
138 keyName1 += OUString().valueOf(i);
139 if (reg_createKey(hRootKey, keyName1.pData, &hKey))
140 cout << "creating key \"" << OUStringToOString(keyName1, RTL_TEXTENCODING_ASCII_US).getStr()
141 << "\" failed\n";
143 for (sal_Int32 j=0; j < S2; j++)
145 keyName2 = sName2;
146 keyName2 += OUString().valueOf(j);
147 if (reg_createKey(hKey, keyName2.pData, &hSubKey))
148 cout << "creating key \"" << OUStringToOString(keyName2, RTL_TEXTENCODING_ASCII_US).getStr()
149 << "\" failed\n";
151 for (sal_Int32 n=0; n < S3; n++)
153 keyName3 = sName3;
154 keyName3 += OUString().valueOf(n);
155 if (reg_createKey(hSubKey, keyName3.pData, &hSubSubKey))
156 cout << "creating key \"" << OUStringToOString(keyName3, RTL_TEXTENCODING_ASCII_US).getStr()
157 << "\" failed\n";
159 if (reg_closeKey(hSubSubKey))
160 cout << "closing key \"" << OUStringToOString(keyName3, RTL_TEXTENCODING_ASCII_US).getStr()
161 << "\" failed\n";
164 if (reg_closeKey(hSubKey))
165 cout << "closing key \"" << OUStringToOString(keyName2, RTL_TEXTENCODING_ASCII_US).getStr()
166 << "\" failed\n";
169 if (reg_closeKey(hKey))
170 cout << "closing key \"" << OUStringToOString(keyName1, RTL_TEXTENCODING_ASCII_US).getStr()
171 << "\" failed\n";
174 aTimer.stop();
176 printf("\n %d keys oeffnen und schliessen dauert ... ", (S1 * S2 * S3));
177 aTimer.start();
179 for (sal_Int32 i=0; i < S1; i++)
181 keyName1 = "/";
182 keyName1 += sName1;
183 keyName1 += OUString().valueOf(i);
184 if (reg_openKey(hRootKey, keyName1.pData, &hKey))
185 cout << "open key \"" << OUStringToOString(keyName1, RTL_TEXTENCODING_ASCII_US).getStr()
186 << "\" failed\n";
188 for (sal_Int32 j=0; j < S2; j++)
190 keyName2 = "/";
191 keyName2 += sName1;
192 keyName2 += OUString().valueOf(i);
193 keyName2 += "/";
194 keyName2 += sName2;
195 keyName2 += OUString().valueOf(j);
196 if (reg_openKey(hRootKey, keyName2.pData, &hSubKey))
197 cout << "open key \"" << OUStringToOString(keyName2, RTL_TEXTENCODING_ASCII_US).getStr()
198 << "\" failed\n";
200 for (sal_Int32 n=0; n < S3; n++)
202 keyName3 = "/";
203 keyName3 += sName1;
204 keyName3 += OUString().valueOf(i);
205 keyName3 += "/";
206 keyName3 += sName2;
207 keyName3 += OUString().valueOf(j);
208 keyName3 += "/";
209 keyName3 += sName3;
210 keyName3 += OUString().valueOf(n);
211 if (reg_openKey(hRootKey, keyName3.pData, &hSubSubKey))
212 cout << "open key \"" << OUStringToOString(keyName3, RTL_TEXTENCODING_ASCII_US).getStr()
213 << "\" failed\n";
215 if (reg_closeKey(hSubSubKey))
216 cout << "open key \"" << OUStringToOString(keyName3, RTL_TEXTENCODING_ASCII_US).getStr()
217 << "\" failed\n";
220 if (reg_closeKey(hSubKey))
221 cout << "closing key \"" << OUStringToOString(keyName2, RTL_TEXTENCODING_ASCII_US).getStr()
222 << "\" failed\n";
225 if (reg_closeKey(hKey))
226 cout << "closing key \"" << OUStringToOString(keyName1, RTL_TEXTENCODING_ASCII_US).getStr()
227 << "\" failed\n";
230 aTimer.stop();
232 printf("\n 1 key oeffnen und schliessen dauert ... ");
233 aTimer.start();
235 if (reg_openKey(hRootKey, keyName3.pData, &hSubSubKey))
236 cout << "open key \"" << OUStringToOString(keyName3, RTL_TEXTENCODING_ASCII_US).getStr()
237 << "\" failed\n";
239 if (reg_closeKey(hSubSubKey))
240 cout << "open key \"" << OUStringToOString(keyName3, RTL_TEXTENCODING_ASCII_US).getStr()
241 << "\" failed\n";
243 aTimer.stop();
247 if (reg_closeKey(hRootKey))
248 cout << "closing root key failed\n";
249 if (reg_closeRegistry(hReg))
250 cout << "\t41. closing registry \"test.reg\" failed\n";
253 return 0;
257 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */