1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: regspeed.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_registry.hxx"
38 #include <sys/timeb.h>
39 #include <sys/types.h>
41 #include "registry/registry.h"
42 #include <rtl/ustring.hxx>
43 #include <rtl/alloc.h>
47 /*****************************************************************
49 *****************************************************************/
54 void start() { _ftime( &m_start
); };
58 m_diff
= difftime(m_stop
.time
, m_start
.time
);
59 if (m_stop
.millitm
> m_start
.millitm
)
61 m_diff
+= ((double)(m_stop
.millitm
- m_start
.millitm
)) / 1000;
66 m_diff
+= ((double)(1000 - (m_start
.millitm
- m_stop
.millitm
))) / 1000;
68 printf(" %.4f Sekunden\n", m_diff
);
73 struct timeb m_start
, m_stop
;
75 struct _timeb m_start
, m_stop
;
80 extern "C" int ftime(struct timeb
*pt
);
85 void start() { ftime( &m_start
); };
89 m_diff
= difftime(m_stop
.time
, m_start
.time
);
90 if (m_stop
.millitm
> m_start
.millitm
)
92 m_diff
+= ((double)(m_stop
.millitm
- m_start
.millitm
)) / 1000;
97 m_diff
+= ((double)(1000 - (m_start
.millitm
- m_stop
.millitm
))) / 1000;
99 printf(" %.4f Sekunden\n", m_diff
);
103 struct timeb m_start
, m_stop
;
110 #if (defined UNX) || (defined OS2)
111 int main( int argc
, char * argv
[] )
113 int _cdecl
main( int argc
, char * argv
[] )
117 RegKeyHandle hRootKey
, hKey
, hSubKey
, hSubSubKey
;
118 OUString
sName1(RTL_CONSTASCII_USTRINGPARAM("regkey"));
119 OUString
sName2(RTL_CONSTASCII_USTRINGPARAM("regSubkey"));
120 OUString
sName3(RTL_CONSTASCII_USTRINGPARAM("regSubSubkey"));
131 cerr
<< "using regspeed count1 count2 count3\n";
139 OUString
speedReg( RTL_CONSTASCII_USTRINGPARAM("speed.reg"));
140 if (reg_createRegistry(speedReg
.pData
, &hReg
))
142 cout
<< "creating registry \"test.reg\" failed\n";
145 if (reg_openRootKey(hReg
, &hRootKey
))
147 cout
<< "open root key \"test.reg\" failed\n";
150 printf("\n %d keys anlegen, oeffnen und schliessen dauert ... ", (S1
* S2
* S3
));
153 for (sal_Int32 i
=0; i
< S1
; i
++)
156 keyName1
+= OUString().valueOf(i
);
157 if (reg_createKey(hRootKey
, keyName1
.pData
, &hKey
))
158 cout
<< "creating key \"" << OUStringToOString(keyName1
, RTL_TEXTENCODING_ASCII_US
).getStr()
161 for (sal_Int32 j
=0; j
< S2
; j
++)
164 keyName2
+= OUString().valueOf(j
);
165 if (reg_createKey(hKey
, keyName2
.pData
, &hSubKey
))
166 cout
<< "creating key \"" << OUStringToOString(keyName2
, RTL_TEXTENCODING_ASCII_US
).getStr()
169 for (sal_Int32 n
=0; n
< S3
; n
++)
172 keyName3
+= OUString().valueOf(n
);
173 if (reg_createKey(hSubKey
, keyName3
.pData
, &hSubSubKey
))
174 cout
<< "creating key \"" << OUStringToOString(keyName3
, RTL_TEXTENCODING_ASCII_US
).getStr()
177 if (reg_closeKey(hSubSubKey
))
178 cout
<< "closing key \"" << OUStringToOString(keyName3
, RTL_TEXTENCODING_ASCII_US
).getStr()
182 if (reg_closeKey(hSubKey
))
183 cout
<< "closing key \"" << OUStringToOString(keyName2
, RTL_TEXTENCODING_ASCII_US
).getStr()
187 if (reg_closeKey(hKey
))
188 cout
<< "closing key \"" << OUStringToOString(keyName1
, RTL_TEXTENCODING_ASCII_US
).getStr()
194 printf("\n %d keys oeffnen und schliessen dauert ... ", (S1
* S2
* S3
));
197 for (sal_Int32 i
=0; i
< S1
; i
++)
199 keyName1
= OUString::createFromAscii("/");
201 keyName1
+= OUString().valueOf(i
);
202 if (reg_openKey(hRootKey
, keyName1
.pData
, &hKey
))
203 cout
<< "open key \"" << OUStringToOString(keyName1
, RTL_TEXTENCODING_ASCII_US
).getStr()
206 for (sal_Int32 j
=0; j
< S2
; j
++)
208 keyName2
= OUString::createFromAscii("/");
210 keyName2
+= OUString().valueOf(i
);
211 keyName2
+= OUString::createFromAscii("/");
213 keyName2
+= OUString().valueOf(j
);
214 if (reg_openKey(hRootKey
, keyName2
.pData
, &hSubKey
))
215 cout
<< "open key \"" << OUStringToOString(keyName2
, RTL_TEXTENCODING_ASCII_US
).getStr()
218 for (sal_Int32 n
=0; n
< S3
; n
++)
220 keyName3
= OUString::createFromAscii("/");
222 keyName3
+= OUString().valueOf(i
);
223 keyName3
+= OUString::createFromAscii("/");
225 keyName3
+= OUString().valueOf(j
);
226 keyName3
+= OUString::createFromAscii("/");
228 keyName3
+= OUString().valueOf(n
);
229 if (reg_openKey(hRootKey
, keyName3
.pData
, &hSubSubKey
))
230 cout
<< "open key \"" << OUStringToOString(keyName3
, RTL_TEXTENCODING_ASCII_US
).getStr()
233 if (reg_closeKey(hSubSubKey
))
234 cout
<< "open key \"" << OUStringToOString(keyName3
, RTL_TEXTENCODING_ASCII_US
).getStr()
238 if (reg_closeKey(hSubKey
))
239 cout
<< "closing key \"" << OUStringToOString(keyName2
, RTL_TEXTENCODING_ASCII_US
).getStr()
243 if (reg_closeKey(hKey
))
244 cout
<< "closing key \"" << OUStringToOString(keyName1
, RTL_TEXTENCODING_ASCII_US
).getStr()
250 printf("\n 1 key oeffnen und schliessen dauert ... ");
253 if (reg_openKey(hRootKey
, keyName3
.pData
, &hSubSubKey
))
254 cout
<< "open key \"" << OUStringToOString(keyName3
, RTL_TEXTENCODING_ASCII_US
).getStr()
257 if (reg_closeKey(hSubSubKey
))
258 cout
<< "open key \"" << OUStringToOString(keyName3
, RTL_TEXTENCODING_ASCII_US
).getStr()
265 if (reg_closeKey(hRootKey
))
266 cout
<< "closing root key failed\n";
267 if (reg_closeRegistry(hReg
))
268 cout
<< "\t41. closing registry \"test.reg\" failed\n";