← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:09 2016

Filename/home/mickey/git_tree/PONAPI/Server/lib/PONAPI/CLI/Command/demo.pm
StatementsExecuted 20 statements in 458µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11117µs176µsPONAPI::CLI::Command::demo::::BEGIN@4PONAPI::CLI::Command::demo::BEGIN@4
11112µs12µsPONAPI::CLI::Command::demo::::validate_argsPONAPI::CLI::Command::demo::validate_args
1117µs18µsPONAPI::CLI::Command::demo::::BEGIN@6PONAPI::CLI::Command::demo::BEGIN@6
1116µs12µsPONAPI::CLI::Command::demo::::BEGIN@7PONAPI::CLI::Command::demo::BEGIN@7
1114µs4µsPONAPI::CLI::Command::demo::::opt_specPONAPI::CLI::Command::demo::opt_spec
0000s0sPONAPI::CLI::Command::demo::::abstractPONAPI::CLI::Command::demo::abstract
0000s0sPONAPI::CLI::Command::demo::::descriptionPONAPI::CLI::Command::demo::description
0000s0sPONAPI::CLI::Command::demo::::executePONAPI::CLI::Command::demo::execute
0000s0sPONAPI::CLI::Command::demo::::run_queryPONAPI::CLI::Command::demo::run_query
0000s0sPONAPI::CLI::Command::demo::::run_serverPONAPI::CLI::Command::demo::run_server
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# ABSTRACT: ponapi demo running command line utility
2package PONAPI::CLI::Command::demo;
3
4230µs2335µs
# spent 176µs (17+159) within PONAPI::CLI::Command::demo::BEGIN@4 which was called: # once (17µs+159µs) by Module::Runtime::require_module at line 4
use PONAPI::CLI -command;
# spent 176µs making 1 call to PONAPI::CLI::Command::demo::BEGIN@4 # spent 159µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
5
6220µs229µs
# spent 18µs (7+11) within PONAPI::CLI::Command::demo::BEGIN@6 which was called: # once (7µs+11µs) by Module::Runtime::require_module at line 6
use strict;
# spent 18µs making 1 call to PONAPI::CLI::Command::demo::BEGIN@6 # spent 11µs making 1 call to strict::import
72284µs218µs
# spent 12µs (6+6) within PONAPI::CLI::Command::demo::BEGIN@7 which was called: # once (6µs+6µs) by Module::Runtime::require_module at line 7
use warnings;
# spent 12µs making 1 call to PONAPI::CLI::Command::demo::BEGIN@7 # spent 6µs making 1 call to warnings::import
8
9sub abstract { "Run a DEMO PONAPI server" }
10sub description { "This tool will run a demo server with a mock DB" }
11
12
# spent 4µs within PONAPI::CLI::Command::demo::opt_spec which was called: # once (4µs+0s) by App::Cmd::Command::_option_processing_params at line 44 of App/Cmd/Command.pm
sub opt_spec {
13 return (
1415µs [ "s|server", "Run a local PONAPI demo server" ],
15 [ "q|query:s", "Send a random/provided query to local server" ],
16 [ "p|port=i", "Specify a port for the server (default=5000)" ],
17 [ "j|json", "JSON-only output" ],
18 );
19}
20
21
# spent 12µs within PONAPI::CLI::Command::demo::validate_args which was called: # once (12µs+0s) by App::Cmd::execute_command at line 467 of App/Cmd.pm
sub validate_args {
221400ns my ( $self, $opt, $args ) = @_;
23
2415µs $self->usage_error("(only) one of server (-s) or query (-q [STR]) is required.\n")
25 unless exists $opt->{s} xor exists $opt->{q};
26
2713µs $self->{port} = $opt->{port} || $opt->{p} || 5000;
28
291700ns $self->{query_string} = "";
30
311600ns if ( exists $opt->{q} and $opt->{q} ) {
32 $opt->{q} =~ s|^/||;
33 $self->{query_string} =
34 ( $opt->{q} !~ /^http/ ? 'http://localhost:' . $self->{port} . '/' : '' )
35 . $opt->{q};
36
37 }
38
3911µs $self->{only_json} = !!( $opt->{json} || $opt->{j} );
4014µs $self->usage_error("JSON-only works just in Query mode")
41 if $self->{only_json} and !exists $opt->{q};
42}
43
44sub execute {
451400ns my ( $self, $opt, $args ) = @_;
46
4712µs $self->run_server() if exists $opt->{s};
48 $self->run_query() if exists $opt->{q};
49}
50
51sub run_server {
521300ns my $self = shift;
53197µs require PONAPI::CLI::RunServer;
5412µs PONAPI::CLI::RunServer::run( $self->{port} );
55}
56
57sub run_query {
58 my $self = shift;
59 require PONAPI::CLI::RunQuery;
60 PONAPI::CLI::RunQuery::run( $self->{port}, $self->{query_string}, $self->{only_json} );
61}
62
6312µs1;