1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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>
34 /*****************************************************************
36 *****************************************************************/
41 void start() { _ftime( &m_start
); };
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;
53 m_diff
+= ((double)(1000 - (m_start
.millitm
- m_stop
.millitm
))) / 1000;
55 printf(" %.4f Sekunden\n", m_diff
);
59 struct _timeb m_start
, m_stop
;
63 extern "C" int ftime(struct timeb
*pt
);
68 void start() { ftime( &m_start
); };
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;
80 m_diff
+= ((double)(1000 - (m_start
.millitm
- m_stop
.millitm
))) / 1000;
82 printf(" %.4f Sekunden\n", m_diff
);
86 struct timeb m_start
, m_stop
;
93 int main( int argc
, char * argv
[] )
95 int _cdecl
main( int argc
, char * argv
[] )
99 RegKeyHandle hRootKey
, hKey
, hSubKey
, hSubSubKey
;
100 OUString
sName1("regkey");
101 OUString
sName2("regSubkey");
102 OUString
sName3("regSubSubkey");
113 cerr
<< "using regspeed count1 count2 count3\n";
121 OUString
speedReg( "speed.reg");
122 if (reg_createRegistry(speedReg
.pData
, &hReg
))
124 cout
<< "creating registry \"test.reg\" failed\n";
127 if (reg_openRootKey(hReg
, &hRootKey
))
129 cout
<< "open root key \"test.reg\" failed\n";
132 printf("\n %d keys anlegen, oeffnen und schliessen dauert ... ", (S1
* S2
* S3
));
135 for (sal_Int32 i
=0; i
< S1
; i
++)
138 keyName1
+= OUString().valueOf(i
);
139 if (reg_createKey(hRootKey
, keyName1
.pData
, &hKey
))
140 cout
<< "creating key \"" << OUStringToOString(keyName1
, RTL_TEXTENCODING_ASCII_US
).getStr()
143 for (sal_Int32 j
=0; j
< S2
; j
++)
146 keyName2
+= OUString().valueOf(j
);
147 if (reg_createKey(hKey
, keyName2
.pData
, &hSubKey
))
148 cout
<< "creating key \"" << OUStringToOString(keyName2
, RTL_TEXTENCODING_ASCII_US
).getStr()
151 for (sal_Int32 n
=0; n
< S3
; n
++)
154 keyName3
+= OUString().valueOf(n
);
155 if (reg_createKey(hSubKey
, keyName3
.pData
, &hSubSubKey
))
156 cout
<< "creating key \"" << OUStringToOString(keyName3
, RTL_TEXTENCODING_ASCII_US
).getStr()
159 if (reg_closeKey(hSubSubKey
))
160 cout
<< "closing key \"" << OUStringToOString(keyName3
, RTL_TEXTENCODING_ASCII_US
).getStr()
164 if (reg_closeKey(hSubKey
))
165 cout
<< "closing key \"" << OUStringToOString(keyName2
, RTL_TEXTENCODING_ASCII_US
).getStr()
169 if (reg_closeKey(hKey
))
170 cout
<< "closing key \"" << OUStringToOString(keyName1
, RTL_TEXTENCODING_ASCII_US
).getStr()
176 printf("\n %d keys oeffnen und schliessen dauert ... ", (S1
* S2
* S3
));
179 for (sal_Int32 i
=0; i
< S1
; i
++)
183 keyName1
+= OUString().valueOf(i
);
184 if (reg_openKey(hRootKey
, keyName1
.pData
, &hKey
))
185 cout
<< "open key \"" << OUStringToOString(keyName1
, RTL_TEXTENCODING_ASCII_US
).getStr()
188 for (sal_Int32 j
=0; j
< S2
; j
++)
192 keyName2
+= OUString().valueOf(i
);
195 keyName2
+= OUString().valueOf(j
);
196 if (reg_openKey(hRootKey
, keyName2
.pData
, &hSubKey
))
197 cout
<< "open key \"" << OUStringToOString(keyName2
, RTL_TEXTENCODING_ASCII_US
).getStr()
200 for (sal_Int32 n
=0; n
< S3
; n
++)
204 keyName3
+= OUString().valueOf(i
);
207 keyName3
+= OUString().valueOf(j
);
210 keyName3
+= OUString().valueOf(n
);
211 if (reg_openKey(hRootKey
, keyName3
.pData
, &hSubSubKey
))
212 cout
<< "open key \"" << OUStringToOString(keyName3
, RTL_TEXTENCODING_ASCII_US
).getStr()
215 if (reg_closeKey(hSubSubKey
))
216 cout
<< "open key \"" << OUStringToOString(keyName3
, RTL_TEXTENCODING_ASCII_US
).getStr()
220 if (reg_closeKey(hSubKey
))
221 cout
<< "closing key \"" << OUStringToOString(keyName2
, RTL_TEXTENCODING_ASCII_US
).getStr()
225 if (reg_closeKey(hKey
))
226 cout
<< "closing key \"" << OUStringToOString(keyName1
, RTL_TEXTENCODING_ASCII_US
).getStr()
232 printf("\n 1 key oeffnen und schliessen dauert ... ");
235 if (reg_openKey(hRootKey
, keyName3
.pData
, &hSubSubKey
))
236 cout
<< "open key \"" << OUStringToOString(keyName3
, RTL_TEXTENCODING_ASCII_US
).getStr()
239 if (reg_closeKey(hSubSubKey
))
240 cout
<< "open key \"" << OUStringToOString(keyName3
, RTL_TEXTENCODING_ASCII_US
).getStr()
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";
257 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */