diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/test/lltiming_tut.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/test/lltiming_tut.cpp')
-rw-r--r-- | linden/indra/test/lltiming_tut.cpp | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/linden/indra/test/lltiming_tut.cpp b/linden/indra/test/lltiming_tut.cpp new file mode 100644 index 0000000..0b503cb --- /dev/null +++ b/linden/indra/test/lltiming_tut.cpp | |||
@@ -0,0 +1,112 @@ | |||
1 | /** | ||
2 | * @file lltiming_tut.cpp | ||
3 | * @date 2006-07-23 | ||
4 | * @brief Tests the timers. | ||
5 | * | ||
6 | * Copyright (c) 2006-2007, Linden Research, Inc. | ||
7 | * | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | #include "linden_common.h" | ||
30 | #include "lltut.h" | ||
31 | |||
32 | #include "llframetimer.h" | ||
33 | #include "llsd.h" | ||
34 | |||
35 | namespace tut | ||
36 | { | ||
37 | struct frametimer_test | ||
38 | { | ||
39 | frametimer_test() | ||
40 | { | ||
41 | LLFrameTimer::updateFrameTime(); | ||
42 | } | ||
43 | }; | ||
44 | typedef test_group<frametimer_test> frametimer_group_t; | ||
45 | typedef frametimer_group_t::object frametimer_object_t; | ||
46 | tut::frametimer_group_t frametimer_instance("frametimer"); | ||
47 | |||
48 | template<> template<> | ||
49 | void frametimer_object_t::test<1>() | ||
50 | { | ||
51 | F64 seconds_since_epoch = LLFrameTimer::getTotalSeconds(); | ||
52 | LLFrameTimer timer; | ||
53 | timer.setExpiryAt(seconds_since_epoch); | ||
54 | F64 expires_at = timer.expiresAt(); | ||
55 | ensure_distance( | ||
56 | "set expiry matches get expiry", | ||
57 | expires_at, | ||
58 | seconds_since_epoch, | ||
59 | 0.001); | ||
60 | } | ||
61 | |||
62 | template<> template<> | ||
63 | void frametimer_object_t::test<2>() | ||
64 | { | ||
65 | F64 seconds_since_epoch = LLFrameTimer::getTotalSeconds(); | ||
66 | seconds_since_epoch += 10.0; | ||
67 | LLFrameTimer timer; | ||
68 | timer.setExpiryAt(seconds_since_epoch); | ||
69 | F64 expires_at = timer.expiresAt(); | ||
70 | ensure_distance( | ||
71 | "set expiry matches get expiry 1", | ||
72 | expires_at, | ||
73 | seconds_since_epoch, | ||
74 | 0.001); | ||
75 | seconds_since_epoch += 10.0; | ||
76 | timer.setExpiryAt(seconds_since_epoch); | ||
77 | expires_at = timer.expiresAt(); | ||
78 | ensure_distance( | ||
79 | "set expiry matches get expiry 2", | ||
80 | expires_at, | ||
81 | seconds_since_epoch, | ||
82 | 0.001); | ||
83 | } | ||
84 | template<> template<> | ||
85 | void frametimer_object_t::test<3>() | ||
86 | { | ||
87 | F64 seconds_since_epoch = LLFrameTimer::getTotalSeconds(); | ||
88 | seconds_since_epoch += 2.0; | ||
89 | LLFrameTimer timer; | ||
90 | timer.setExpiryAt(seconds_since_epoch); | ||
91 | ensure("timer not expired on create", !timer.hasExpired()); | ||
92 | int ii; | ||
93 | for(ii = 0; ii < 10; ++ii) | ||
94 | { | ||
95 | ms_sleep(150); | ||
96 | LLFrameTimer::updateFrameTime(); | ||
97 | } | ||
98 | ensure("timer not expired after a bit", !timer.hasExpired()); | ||
99 | for(ii = 0; ii < 10; ++ii) | ||
100 | { | ||
101 | ms_sleep(100); | ||
102 | LLFrameTimer::updateFrameTime(); | ||
103 | } | ||
104 | ensure("timer expired", timer.hasExpired()); | ||
105 | } | ||
106 | /* | ||
107 | template<> template<> | ||
108 | void frametimer_object_t::test<4>() | ||
109 | { | ||
110 | } | ||
111 | */ | ||
112 | } | ||