| Filename | /server-root/ashesofangels.com/htdocs/test/cron/tick/move_planets.pl |
| Statements | Executed 4311 statements in 20.4ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1107 | 1 | 1 | 2.29s | 2.29s | DBI::st::execute (xsub) |
| 1107 | 1 | 1 | 10.2ms | 77.2ms | DBI::db::prepare (xsub) |
| 1 | 1 | 1 | 4.09ms | 12.0ms | main::BEGIN@39 |
| 1107 | 1 | 1 | 3.42ms | 3.42ms | DBI::st::finish (xsub) |
| 2216 | 2 | 2 | 3.27ms | 3.27ms | DBI::common::DESTROY (xsub) |
| 1107 | 1 | 1 | 2.70ms | 2.70ms | DBI::common::func (xsub) |
| 1 | 1 | 1 | 1.68ms | 1.74ms | Exporter::export_ok_tags |
| 15 | 13 | 7 | 1.56ms | 1.66ms | Exporter::import |
| 1108 | 2 | 2 | 994µs | 994µs | DBD::_mem::common::DESTROY (xsub) |
| 200 | 1 | 1 | 382µs | 382µs | DBI::st::fetchrow_array (xsub) |
| 26 | 26 | 11 | 164µs | 164µs | strict::unimport |
| 1 | 1 | 1 | 144µs | 144µs | DBI::db::disconnect (xsub) |
| 7 | 7 | 7 | 111µs | 111µs | warnings::import |
| 27 | 27 | 20 | 82µs | 82µs | strict::import |
| 3 | 1 | 1 | 50µs | 50µs | warnings::register_categories |
| 10 | 3 | 1 | 49µs | 49µs | DBI::common::STORE (xsub) |
| 3 | 3 | 2 | 44µs | 44µs | warnings::unimport |
| 12 | 2 | 1 | 36µs | 36µs | UNIVERSAL::isa (xsub) |
| 2 | 1 | 1 | 22µs | 5.52ms | DBI::dr::connect (xsub) |
| 1 | 1 | 1 | 16µs | 16µs | Getopt::Std::getopts |
| 1 | 1 | 1 | 13µs | 13µs | DBI::dr::disconnect_all (xsub) |
| 7 | 3 | 1 | 8µs | 8µs | Internals::SvREADONLY (xsub) |
| 5 | 1 | 1 | 8µs | 8µs | mro::method_changed_in (xsub) |
| 1 | 1 | 1 | 6µs | 6µs | version::(cmp (xsub) |
| 1 | 1 | 1 | 6µs | 6µs | UNIVERSAL::VERSION (xsub) |
| 2 | 1 | 1 | 6µs | 6µs | DBI::db::connected (xsub) |
| 1 | 1 | 1 | 5µs | 5µs | version::(bool (xsub) |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 0 | 1 | 171µs | Profile data that couldn't be associated with a specific line: # spent 171µs making 1 call to DBI::END | ||
| 1 | 1 | 123µs | |||
| - - | |||||
| 11 | 1 | 1µs | my %options = (); | ||
| 12 | 1 | 21µs | 1 | 16µs | getopts( "s:", \%options );# reads the defined flags into %options # spent 16µs making 1 call to Getopt::Std::getopts |
| 13 | |||||
| 14 | 1 | 800ns | my $crondir = "/aoa_test/cron"; | ||
| 15 | 1 | 1µs | if ( defined( $options{s} ) && $options{s} eq 'pr' ) { | ||
| 16 | # set for pr | ||||
| 17 | $crondir = "/aoa_pr/cron"; | ||||
| 18 | } elsif ( defined( $options{s} ) && $options{s} eq 'env' ) { | ||||
| 19 | # get from ENV variable | ||||
| 20 | $crondir = $ENV{aoa_crondir}; | ||||
| 21 | } else { | ||||
| 22 | # default to test if no matching option is set | ||||
| 23 | 1 | 600ns | $crondir = "/aoa_test/cron"; | ||
| 24 | } | ||||
| 25 | |||||
| 26 | 1 | 47µs | 1 | 27µs | print "$crondir $0\n";# print cron dir and scriptname # spent 27µs making 1 call to main::CORE:print |
| 27 | 1 | 19µs | 1 | 4µs | print "started: " . localtime() . "\n"; # spent 4µs making 1 call to main::CORE:print |
| 28 | |||||
| 29 | # connect to db | ||||
| 30 | 1 | 84µs | require "$crondir/dbsetup.pl"; | ||
| 31 | 1 | 78µs | require "$crondir/db/mysql.pl"; | ||
| 32 | 1 | 112µs | require "$crondir/utils/utils.pl"; | ||
| 33 | 1 | 3µs | 1 | 638µs | my $dbh=&db_setup; # spent 638µs making 1 call to main::db_setup |
| 34 | |||||
| 35 | ####################### | ||||
| 36 | # global variables# | ||||
| 37 | ####################### | ||||
| 38 | 1 | 9µs | my $debug = 0; | ||
| 39 | 2 | 637µs | 2 | 13.1ms | # spent 12.0ms (4.09+7.90) within main::BEGIN@39 which was called:
# once (4.09ms+7.90ms) by main::NULL at line 39 # spent 12.0ms making 1 call to main::BEGIN@39
# spent 1.10ms making 1 call to POSIX::import |
| 40 | 1 | 1µs | my $pi=3.1415927/180; | ||
| 41 | |||||
| 42 | 1 | 500ns | my (%x,%y,%z); | ||
| 43 | 1 | 5µs | 1 | 1.71ms | my(@centres)=db_domyquery($dbh,"SELECT `id`,`x`,`y`,`z` FROM `solar_systems`"); # spent 1.71ms making 1 call to main::db_domyquery |
| 44 | 1 | 1µs | while(@centres) { | ||
| 45 | 14 | 10µs | my($id,$x,$y,$z)=splice(@centres,0,4); | ||
| 46 | 14 | 13µs | $x{$id}=$x; | ||
| 47 | 14 | 8µs | $y{$id}=$y; | ||
| 48 | 14 | 13µs | $z{$id}=$z; | ||
| 49 | } | ||||
| 50 | |||||
| 51 | 1 | 64µs | 1 | 2.18ms | my(@planets)=db_domyquery($dbh,"SELECT `id`,`x`,`y`,`z`,`year_length`,`distance_au`,`system_id`,`angle`,`angle_inc`,`z_angle` FROM `planets` WHERE `circular`=1 and `sg_temp`=0"); # spent 2.18ms making 1 call to main::db_domyquery |
| 52 | 1 | 1µs | while(@planets) { | ||
| 53 | 184 | 1.05ms | my($pid,$px,$py,$pz,$yl,$dist,$s_id,$angle,$angle_inc,$z_angle)=splice(@planets,0,10); | ||
| 54 | 184 | 112µs | if ( $debug ) { | ||
| 55 | print "$pid,$px,$py,$pz,$yl,$dist,$s_id,$angle,$angle_inc\n"; | ||||
| 56 | } | ||||
| 57 | 184 | 140µs | my $old_x=$px; | ||
| 58 | 184 | 89µs | my $old_y=$py; | ||
| 59 | 184 | 86µs | my $old_z=$pz; | ||
| 60 | 184 | 1.44ms | $px-=$x{$s_id}; | ||
| 61 | 184 | 315µs | $py-=$y{$s_id}; | ||
| 62 | 184 | 275µs | $pz-=$z{$s_id}; | ||
| 63 | 184 | 101µs | if ( $debug ) { | ||
| 64 | print "$pid,$px,$py,$pz,$yl,$dist,$s_id,$angle,$angle_inc\n"; | ||||
| 65 | } | ||||
| 66 | 184 | 913µs | $px=$dist*cos(($angle+$angle_inc)*$pi); | ||
| 67 | 184 | 269µs | $py=$dist*sin(($angle+$angle_inc)*$pi); | ||
| 68 | 184 | 253µs | $pz=$z_angle*cos(($angle+$angle_inc)*$pi); #don't need $dist for the z_axis as $z_angle serves this purpose | ||
| 69 | 184 | 76µs | if ( $debug ) { | ||
| 70 | print "$pid,$px,$py,$pz,$yl,$dist,$s_id,$angle,$angle_inc\n"; | ||||
| 71 | } | ||||
| 72 | 184 | 185µs | $px+=$x{$s_id}; | ||
| 73 | 184 | 106µs | $py+=$y{$s_id}; | ||
| 74 | 184 | 121µs | $pz+=$z{$s_id}; | ||
| 75 | 184 | 50µs | if ( $debug ) { | ||
| 76 | print "$pid,$px,$py,$pz,$yl,$dist,$s_id,$angle,$angle_inc\n"; | ||||
| 77 | } | ||||
| 78 | 184 | 1.84ms | 184 | 847ms | db_domyquery($dbh,"UPDATE `planets` SET `x`=$px,`y`=$py,`z`=$pz,`angle`=`angle`+`angle_inc` WHERE `id`=$pid"); # spent 847ms making 184 calls to main::db_domyquery, avg 4.60ms/call |
| 79 | |||||
| 80 | #now find any players,etc who are at this planet and move them as well, but only as long as they weren't travelling somewhere | ||||
| 81 | 184 | 2.92ms | 184 | 1.14s | db_domyquery($dbh,"UPDATE `users` SET `x`=$px,`y`=$py,`z`=$pz,`dest_x`=$px,`dest_y`=$py,`dest_z`=$pz WHERE `at_planet`=$pid AND `x`=`dest_x` AND `y`=`dest_y` AND `z`=`dest_z`"); # spent 1.14s making 184 calls to main::db_domyquery, avg 6.20ms/call |
| 82 | #update players who were at this planet | ||||
| 83 | 184 | 2.12ms | 184 | 105ms | db_domyquery($dbh,"UPDATE `users` SET `x`=$px,`y`=$py,`z`=$pz WHERE `at_planet`=$pid"); # spent 105ms making 184 calls to main::db_domyquery, avg 568µs/call |
| 84 | #update players who were travelling to this planet | ||||
| 85 | 184 | 1.79ms | 184 | 178ms | db_domyquery($dbh,"UPDATE `users` SET `dest_x`=$px,`dest_y`=$py,`dest_z`=$pz WHERE `dest_x`=$old_x AND `dest_y`=$old_y AND `dest_z`=$old_z"); # spent 178ms making 184 calls to main::db_domyquery, avg 966µs/call |
| 86 | #update players who were travelling to this planet, but already at another planet... | ||||
| 87 | 184 | 1.74ms | 184 | 93.6ms | db_domyquery($dbh,"UPDATE `users` SET `x`=$px,`y`=$py,`z`=$pz WHERE `at_planet`=$pid AND (`x`!=`dest_x` OR `y`!=`dest_y` OR `z`!=`dest_z`)"); # spent 93.6ms making 184 calls to main::db_domyquery, avg 509µs/call |
| 88 | #update any waypoints that were set to this planet | ||||
| 89 | 184 | 2.48ms | 184 | 54.6ms | db_domyquery($dbh,"UPDATE `waypoints` SET `x`=$px,`y`=$py,`z`=$pz WHERE `planet_id`=$pid"); # spent 54.6ms making 184 calls to main::db_domyquery, avg 296µs/call |
| 90 | } | ||||
| 91 | |||||
| 92 | # reset any planets that have completed a complete orbit | ||||
| 93 | 1 | 4µs | 1 | 4.37ms | db_domyquery($dbh,"UPDATE `planets` SET `angle`=`angle`-360 WHERE `angle`>360"); # spent 4.37ms making 1 call to main::db_domyquery |
| 94 | |||||
| 95 | |||||
| 96 | 1 | 5µs | 1 | 163µs | db_close($dbh); # spent 163µs making 1 call to main::db_close |
| 97 | |||||
| 98 | 1 | 716µs | 4 | 583µs | print "\nfinished: ".localtime()."\n"; # spent 449µs making 1 call to main::CORE:print
# spent 128µs making 2 calls to DBI::common::DESTROY, avg 64µs/call
# spent 7µs making 1 call to DBD::_mem::common::DESTROY |
| 99 | |||||
| 100 | # | ||||
| 101 | # End of script | ||||
| 102 | # | ||||
# spent 994µs within DBD::_mem::common::DESTROY which was called 1108 times, avg 897ns/call:
# 1107 times (987µs+0s) by main::db_domyquery at line 37 of /aoa_test/cron/db/mysql.pl, avg 892ns/call
# once (7µs+0s) by main::RUNTIME at line 98 | |||||
# spent 3.27ms within DBI::common::DESTROY which was called 2216 times, avg 1µs/call:
# 2214 times (3.14ms+0s) by main::db_domyquery at line 37 of /aoa_test/cron/db/mysql.pl, avg 1µs/call
# 2 times (128µs+0s) by main::RUNTIME at line 98, avg 64µs/call | |||||
# spent 49µs within DBI::common::STORE which was called 10 times, avg 5µs/call:
# 4 times (32µs+0s) by DBI::__ANON__[/usr/local/lib/perl5/site_perl/mach/5.36/DBI.pm:746] at line 731 of DBI.pm, avg 8µs/call
# 4 times (13µs+0s) by DBI::__ANON__[/usr/local/lib/perl5/site_perl/mach/5.36/DBI.pm:746] at line 734 of DBI.pm, avg 3µs/call
# 2 times (4µs+0s) by DBI::connect at line 750 of DBI.pm, avg 2µs/call | |||||
# spent 2.70ms within DBI::common::func which was called 1107 times, avg 2µs/call:
# 1107 times (2.70ms+0s) by DBD::mysql::db::prepare at line 235 of DBD/mysql.pm, avg 2µs/call | |||||
# spent 6µs within DBI::db::connected which was called 2 times, avg 3µs/call:
# 2 times (6µs+0s) by DBI::__ANON__[/usr/local/lib/perl5/site_perl/mach/5.36/DBI.pm:746] at line 741 of DBI.pm, avg 3µs/call | |||||
# spent 144µs within DBI::db::disconnect which was called:
# once (144µs+0s) by main::db_close at line 16 of /aoa_test/cron/db/mysql.pl | |||||
# spent 77.2ms (10.2+67.0) within DBI::db::prepare which was called 1107 times, avg 70µs/call:
# 1107 times (10.2ms+67.0ms) by main::db_domyquery at line 21 of /aoa_test/cron/db/mysql.pl, avg 70µs/call | |||||
# spent 5.52ms (22µs+5.50) within DBI::dr::connect which was called 2 times, avg 2.76ms/call:
# 2 times (22µs+5.50ms) by DBI::__ANON__[/usr/local/lib/perl5/site_perl/mach/5.36/DBI.pm:746] at line 679 of DBI.pm, avg 2.76ms/call | |||||
# spent 13µs within DBI::dr::disconnect_all which was called:
# once (13µs+0s) by DBI::disconnect_all at line 759 of DBI.pm | |||||
# spent 2.29s within DBI::st::execute which was called 1107 times, avg 2.07ms/call:
# 1107 times (2.29s+0s) by main::db_domyquery at line 23 of /aoa_test/cron/db/mysql.pl, avg 2.07ms/call | |||||
# spent 382µs within DBI::st::fetchrow_array which was called 200 times, avg 2µs/call:
# 200 times (382µs+0s) by main::db_domyquery at line 29 of /aoa_test/cron/db/mysql.pl, avg 2µs/call | |||||
# spent 3.42ms within DBI::st::finish which was called 1107 times, avg 3µs/call:
# 1107 times (3.42ms+0s) by main::db_domyquery at line 36 of /aoa_test/cron/db/mysql.pl, avg 3µs/call | |||||
# spent 8µs within Internals::SvREADONLY which was called 7 times, avg 1µs/call:
# 5 times (6µs+0s) by constant::import at line 164 of constant.pm, avg 1µs/call
# once (1µs+0s) by constant::BEGIN@24 at line 33 of constant.pm
# once (500ns+0s) by constant::BEGIN@24 at line 34 of constant.pm | |||||
# spent 6µs within UNIVERSAL::VERSION which was called:
# once (6µs+0s) by DBI::BEGIN@174 at line 24 of Scalar/Util.pm | |||||
# spent 36µs within UNIVERSAL::isa which was called 12 times, avg 3µs/call:
# 6 times (23µs+0s) by DBI::setup_driver at line 853 of DBI.pm, avg 4µs/call
# 6 times (13µs+0s) by DBI::setup_driver at line 858 of DBI.pm, avg 2µs/call | |||||
# spent 8µs within mro::method_changed_in which was called 5 times, avg 2µs/call:
# 5 times (8µs+0s) by constant::import at line 198 of constant.pm, avg 2µs/call | |||||
# spent 5µs within version::(bool which was called:
# once (5µs+0s) by DynaLoader::BEGIN@32 at line 59 of Config.pm | |||||
# spent 6µs within version::(cmp which was called:
# once (6µs+0s) by DynaLoader::BEGIN@32 at line 62 of Config.pm |