|
1 /* |
|
2 Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
3 |
|
4 Redistribution and use in source and binary forms, with or without |
|
5 modification, are permitted provided that the following conditions are met: |
|
6 |
|
7 * Redistributions of source code must retain the above copyright notice, this |
|
8 list of conditions and the following disclaimer. |
|
9 * Redistributions in binary form must reproduce the above copyright notice, |
|
10 this list of conditions and the following disclaimer in the documentation |
|
11 and/or other materials provided with the distribution. |
|
12 * Neither the name of Nokia Corporation nor the names of its contributors |
|
13 may be used to endorse or promote products derived from this software |
|
14 without specific prior written permission. |
|
15 |
|
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
|
20 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
21 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
|
22 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
23 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
|
24 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
25 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
26 |
|
27 * Description: |
|
28 * |
|
29 */ |
|
30 |
|
31 |
|
32 #include <boost/config.hpp> |
|
33 |
|
34 #if defined(BOOST_MSVC) |
|
35 #pragma warning(disable: 4786) // identifier truncated in debug info |
|
36 #pragma warning(disable: 4710) // function not inlined |
|
37 #pragma warning(disable: 4711) // function selected for automatic inline expansion |
|
38 #pragma warning(disable: 4514) // unreferenced inline removed |
|
39 #endif |
|
40 |
|
41 // |
|
42 // shared_ptr_timing_test.cpp - use to evaluate the impact of thread safety |
|
43 // |
|
44 // Copyright (c) 2002 Peter Dimov and Multi Media Ltd. |
|
45 // |
|
46 // Distributed under the Boost Software License, Version 1.0. (See |
|
47 // accompanying file LICENSE_1_0.txt or copy at |
|
48 // http://www.boost.org/LICENSE_1_0.txt) |
|
49 // |
|
50 |
|
51 #include <boost/shared_ptr.hpp> |
|
52 #include <iostream> |
|
53 #include <vector> |
|
54 #include <ctime> |
|
55 |
|
56 #ifdef __SYMBIAN32__ |
|
57 #include "std_log_result.h" |
|
58 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
|
59 #endif |
|
60 |
|
61 #ifdef __SYMBIAN32__ |
|
62 int const n = 1024; |
|
63 #else |
|
64 int const n = 8 * 1024 * 1024; |
|
65 #endif |
|
66 |
|
67 int main() |
|
68 { |
|
69 std_log(LOG_FILENAME_LINE,"[Test Case for shared_ptr_timing_test]"); |
|
70 using namespace std; |
|
71 |
|
72 std::vector< boost::shared_ptr<int> > v; |
|
73 boost::shared_ptr<int> pi(new int); |
|
74 |
|
75 clock_t t = clock(); |
|
76 |
|
77 for(int i = 0; i < n; ++i) |
|
78 { |
|
79 v.push_back(pi); |
|
80 } |
|
81 |
|
82 t = clock() - t; |
|
83 |
|
84 std::cout << static_cast<double>(t) / CLK_TCK << '\n'; |
|
85 |
|
86 #ifdef __SYMBIAN32__ |
|
87 std_log(LOG_FILENAME_LINE,"Result : Passed"); |
|
88 std_log(LOG_FILENAME_LINE,"[End Test Case ]"); |
|
89 #endif |
|
90 testResultXml("shared_ptr_timing_test"); |
|
91 close_log_file(); |
|
92 return 0; |
|
93 } |