← Index
NYTProf Performance Profile   « line view »
For ./move_planets.pl
  Run on Tue Jan 23 21:11:41 2024
Reported on Tue Jan 23 21:12:47 2024

Filename/server-root/ashesofangels.com/htdocs/test/cron/tick/move_planets.pl
StatementsExecuted 4311 statements in 20.4ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1107112.29s2.29sDBI::st::::execute DBI::st::execute (xsub)
11071110.2ms77.2msDBI::db::::prepare DBI::db::prepare (xsub)
1114.09ms12.0msmain::::BEGIN@39 main::BEGIN@39
1107113.42ms3.42msDBI::st::::finish DBI::st::finish (xsub)
2216223.27ms3.27msDBI::common::::DESTROY DBI::common::DESTROY (xsub)
1107112.70ms2.70msDBI::common::::func DBI::common::func (xsub)
1111.68ms1.74msExporter::::export_ok_tags Exporter::export_ok_tags
151371.56ms1.66msExporter::::import Exporter::import
110822994µs994µsDBD::_mem::common::::DESTROYDBD::_mem::common::DESTROY (xsub)
20011382µs382µsDBI::st::::fetchrow_array DBI::st::fetchrow_array (xsub)
262611164µs164µsstrict::::unimport strict::unimport
111144µs144µsDBI::db::::disconnect DBI::db::disconnect (xsub)
777111µs111µswarnings::::import warnings::import
27272082µs82µsstrict::::import strict::import
31150µs50µswarnings::::register_categories warnings::register_categories
103149µs49µsDBI::common::::STORE DBI::common::STORE (xsub)
33244µs44µswarnings::::unimport warnings::unimport
122136µs36µsUNIVERSAL::::isa UNIVERSAL::isa (xsub)
21122µs5.52msDBI::dr::::connect DBI::dr::connect (xsub)
11116µs16µsGetopt::Std::::getopts Getopt::Std::getopts
11113µs13µsDBI::dr::::disconnect_all DBI::dr::disconnect_all (xsub)
7318µs8µsInternals::::SvREADONLY Internals::SvREADONLY (xsub)
5118µs8µsmro::::method_changed_in mro::method_changed_in (xsub)
1116µs6µsversion::::(cmp version::(cmp (xsub)
1116µs6µsUNIVERSAL::::VERSION UNIVERSAL::VERSION (xsub)
2116µs6µsDBI::db::::connected DBI::db::connected (xsub)
1115µs5µsversion::::(bool version::(bool (xsub)
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
01171µsProfile data that couldn't be associated with a specific line:
# spent 171µs making 1 call to DBI::END
11123µs
- -
1111µsmy %options = ();
12121µs116µsgetopts( "s:", \%options );# reads the defined flags into %options
# spent 16µs making 1 call to Getopt::Std::getopts
13
141800nsmy $crondir = "/aoa_test/cron";
1511µsif ( 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
231600ns $crondir = "/aoa_test/cron";
24}
25
26147µs127µsprint "$crondir $0\n";# print cron dir and scriptname
# spent 27µs making 1 call to main::CORE:print
27119µs14µsprint "started: " . localtime() . "\n";
# spent 4µs making 1 call to main::CORE:print
28
29# connect to db
30184µsrequire "$crondir/dbsetup.pl";
31178µsrequire "$crondir/db/mysql.pl";
321112µsrequire "$crondir/utils/utils.pl";
3313µs1638µsmy $dbh=&db_setup;
# spent 638µs making 1 call to main::db_setup
34
35#######################
36# global variables#
37#######################
3819µsmy $debug = 0;
392637µs213.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
use POSIX qw(strftime mktime);
# spent 12.0ms making 1 call to main::BEGIN@39 # spent 1.10ms making 1 call to POSIX::import
4011µsmy $pi=3.1415927/180;
41
421500nsmy (%x,%y,%z);
4315µs11.71msmy(@centres)=db_domyquery($dbh,"SELECT `id`,`x`,`y`,`z` FROM `solar_systems`");
# spent 1.71ms making 1 call to main::db_domyquery
4411µswhile(@centres) {
451410µs my($id,$x,$y,$z)=splice(@centres,0,4);
461413µs $x{$id}=$x;
47148µs $y{$id}=$y;
481413µs $z{$id}=$z;
49}
50
51164µs12.18msmy(@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
5211µswhile(@planets) {
531841.05ms my($pid,$px,$py,$pz,$yl,$dist,$s_id,$angle,$angle_inc,$z_angle)=splice(@planets,0,10);
54184112µs if ( $debug ) {
55 print "$pid,$px,$py,$pz,$yl,$dist,$s_id,$angle,$angle_inc\n";
56 }
57184140µs my $old_x=$px;
5818489µs my $old_y=$py;
5918486µs my $old_z=$pz;
601841.44ms $px-=$x{$s_id};
61184315µs $py-=$y{$s_id};
62184275µs $pz-=$z{$s_id};
63184101µs if ( $debug ) {
64 print "$pid,$px,$py,$pz,$yl,$dist,$s_id,$angle,$angle_inc\n";
65 }
66184913µs $px=$dist*cos(($angle+$angle_inc)*$pi);
67184269µs $py=$dist*sin(($angle+$angle_inc)*$pi);
68184253µs $pz=$z_angle*cos(($angle+$angle_inc)*$pi); #don't need $dist for the z_axis as $z_angle serves this purpose
6918476µs if ( $debug ) {
70 print "$pid,$px,$py,$pz,$yl,$dist,$s_id,$angle,$angle_inc\n";
71 }
72184185µs $px+=$x{$s_id};
73184106µs $py+=$y{$s_id};
74184121µs $pz+=$z{$s_id};
7518450µs if ( $debug ) {
76 print "$pid,$px,$py,$pz,$yl,$dist,$s_id,$angle,$angle_inc\n";
77 }
781841.84ms184847ms 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
811842.92ms1841.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
831842.12ms184105ms 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
851841.79ms184178ms 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...
871841.74ms18493.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
891842.48ms18454.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
9314µs14.37msdb_domyquery($dbh,"UPDATE `planets` SET `angle`=`angle`-360 WHERE `angle`>360");
# spent 4.37ms making 1 call to main::db_domyquery
94
95
9615µs1163µsdb_close($dbh);
# spent 163µs making 1 call to main::db_close
97
981716µs4583µsprint "\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
sub DBD::_mem::common::DESTROY; # xsub
# 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
sub DBI::common::DESTROY; # xsub
# 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
sub DBI::common::STORE; # xsub
# 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
sub DBI::common::func; # xsub
# 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
sub DBI::db::connected; # xsub
# 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
sub DBI::db::disconnect; # xsub
# 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
sub DBI::db::prepare; # xsub
# 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
sub DBI::dr::connect; # xsub
# 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
sub DBI::dr::disconnect_all; # xsub
# 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
sub DBI::st::execute; # xsub
# 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
sub DBI::st::fetchrow_array; # xsub
# 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
sub DBI::st::finish; # xsub
# 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
sub Internals::SvREADONLY; # xsub
# spent 6µs within UNIVERSAL::VERSION which was called: # once (6µs+0s) by DBI::BEGIN@174 at line 24 of Scalar/Util.pm
sub UNIVERSAL::VERSION; # xsub
# 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
sub UNIVERSAL::isa; # xsub
# 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
sub mro::method_changed_in; # xsub
# spent 5µs within version::(bool which was called: # once (5µs+0s) by DynaLoader::BEGIN@32 at line 59 of Config.pm
sub version::(bool; # xsub
# spent 6µs within version::(cmp which was called: # once (6µs+0s) by DynaLoader::BEGIN@32 at line 62 of Config.pm
sub version::(cmp; # xsub