9 #include "pol_global_config.h" 11 #ifdef ENABLE_BENCHMARK 12 #include "../module/uomod.h" 13 #include "../scrsched.h" 14 #include "../uoexec.h" 15 #include "../uoscrobj.h" 16 #include <benchmark/benchmark.h> 19 #include "../../clib/logfacility.h" 20 #include "../../clib/rawtypes.h" 21 #include "../globals/uvars.h" 22 #include "../item/item.h" 24 #include "../mobile/npc.h" 25 #include "../realms/realm.h" 26 #include "../uobject.h" 34 void test_los( Core::UObject* src, Core::UObject* target,
bool should_have_los )
36 #ifndef ENABLE_BENCHMARK 37 INFO_PRINT <<
"LOS test: " << src->name() <<
" to " << target->name() <<
"(" << should_have_los
42 #ifdef ENABLE_BENCHMARK 47 if ( should_have_los == res )
59 void test_los(
u16 x1,
u16 y1,
s8 z1,
u16 x2,
u16 y2,
s8 z2,
bool should_have_los )
61 #ifndef ENABLE_BENCHMARK 62 INFO_PRINT <<
"LOS test: (" << x1 <<
"," << y1 <<
"," << int( z1 ) <<
")" 63 <<
" - (" << x2 <<
"," << y2 <<
"," << int( z2 ) <<
")" 64 <<
" (" << should_have_los <<
"):";
67 bool res = main_realm->
has_los( Core::LosObj( x1, y1, z1, main_realm ),
68 Core::LosObj( x2, y2, z2, main_realm ) );
69 #ifdef ENABLE_BENCHMARK 74 if ( should_have_los == res )
86 void test_los(
u16 x1,
u16 y1,
s8 z1,
u8 h1,
u16 x2,
u16 y2,
s8 z2,
u8 h2,
bool should_have_los )
88 #ifndef ENABLE_BENCHMARK 89 INFO_PRINT <<
"LOS test: (" << x1 <<
"," << y1 <<
"," << int( z1 ) <<
",ht=" << int( h1 ) <<
")" 90 <<
" - (" << x2 <<
"," << y2 <<
"," << int( z2 ) <<
",ht=" << int( h2 ) <<
")" 91 <<
" (" << should_have_los <<
"):";
94 bool res = main_realm->
has_los( Core::LosObj( x1, y1, z1, main_realm ),
95 Core::LosObj( x2, y2, z2, main_realm ) );
96 #ifdef ENABLE_BENCHMARK 101 if ( should_have_los == res )
116 #ifndef ENABLE_BENCHMARK 119 test_los( 5421, 78, 10, 5422, 89, 20,
false );
120 test_los( 1403, 1624, 28, 1402, 1625, 28,
true );
122 test_los( 1374, 1625, 59, 1379, 1625, 30,
true );
123 test_los( 1373, 1625, 59, 1379, 1625, 30,
true );
124 test_los( 1372, 1625, 59, 1379, 1625, 30,
false );
125 test_los( 1372, 1625, 59, 1381, 1625, 30,
true );
128 test_los( 5987, 1999, 7 + 9, 5991, 2001, 1,
false );
129 test_los( 5987, 1999, 7 + 9, 5993, 1997, 1,
false );
132 test_los( 5583, 226, 0, 5590, 223, 0,
false );
141 test_los( 579, 2106, 0, 1, 563, 2107, 0, 1,
false );
142 test_los( 862, 1691, 0, 1, 843, 1689, 0, 1,
true );
143 test_los( 1618, 3351, 3, 1, 1618, 3340, 4, 1,
true );
146 #ifdef ENABLE_BENCHMARK 148 static void BM_los( benchmark::State& state )
150 while ( state.KeepRunning() )
157 static void BM_los100inside100outside( benchmark::State& state )
159 while ( state.KeepRunning() )
161 test_los( 1373, 1625, 59, 1379, 1625, 30,
true );
166 static void BM_method( benchmark::State& state )
170 ex->addModule( uoemod );
174 while ( state.KeepRunning() )
176 ref->call_method(
"test", *( ex.get() ) );
182 BENCHMARK( BM_method );
183 static void BM_member_id( benchmark::State& state )
188 while ( state.KeepRunning() )
190 ref->get_member_id( 1 );
196 BENCHMARK( BM_member_id );
static Item * create(u32 objtype, u32 serial=0)
Mobile::NPC * test_banker2
UOExecutor * create_script_executor()
bool has_los(const Core::ULWObject &att, const Core::ULWObject &tgt) const
Mobile::NPC * test_orclord
Mobile::NPC * test_banker3
Realms::Realm * main_realm