← Index
NYTProf Performance Profile   « line view »
For webmerge/scripts/webmerge.pl
  Run on Mon Oct 7 02:42:42 2013
Reported on Mon Oct 7 03:03:23 2013

Filename/home/ocbnet/domain/ocbnet.ch/vhost/webmerge/htdocs/webmerge/scripts/modules/RTP/Webmerge/Compile/JS.pm
StatementsExecuted 16 statements in 3.23ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11114.9ms138msRTP::Webmerge::Compile::JS::::BEGIN@26RTP::Webmerge::Compile::JS::BEGIN@26
11189µs401µsRTP::Webmerge::Compile::JS::::BEGIN@8RTP::Webmerge::Compile::JS::BEGIN@8
11163µs658µsRTP::Webmerge::Compile::JS::::BEGIN@29RTP::Webmerge::Compile::JS::BEGIN@29
11155µs89µsRTP::Webmerge::Compile::JS::::BEGIN@10RTP::Webmerge::Compile::JS::BEGIN@10
11154µs54µsRTP::Webmerge::Compile::JS::::BEGIN@18.27RTP::Webmerge::Compile::JS::BEGIN@18.27
11153µs141µsRTP::Webmerge::Compile::JS::::BEGIN@9RTP::Webmerge::Compile::JS::BEGIN@9
11129µs29µsRTP::Webmerge::Compile::JS::::BEGIN@21RTP::Webmerge::Compile::JS::BEGIN@21
11124µs24µsRTP::Webmerge::Compile::JS::::BEGIN@18RTP::Webmerge::Compile::JS::BEGIN@18
11124µs24µsRTP::Webmerge::Compile::JS::::BEGIN@15RTP::Webmerge::Compile::JS::BEGIN@15
0000s0sRTP::Webmerge::Compile::JS::::compileJSRTP::Webmerge::Compile::JS::compileJS
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1###################################################################################################
2# Copyright 2013 by Marcel Greter
3# This file is part of Webmerge (GPL3)
4###################################################################################################
5package RTP::Webmerge::Compile::JS;
6###################################################################################################
7
82168µs2713µs
# spent 401µs (89+312) within RTP::Webmerge::Compile::JS::BEGIN@8 which was called: # once (89µs+312µs) by main::BEGIN@40 at line 8
use Carp;
# spent 401µs making 1 call to RTP::Webmerge::Compile::JS::BEGIN@8 # spent 312µs making 1 call to Exporter::import
92172µs2229µs
# spent 141µs (53+88) within RTP::Webmerge::Compile::JS::BEGIN@9 which was called: # once (53µs+88µs) by main::BEGIN@40 at line 9
use strict;
# spent 141µs making 1 call to RTP::Webmerge::Compile::JS::BEGIN@9 # spent 88µs making 1 call to strict::import
102200µs2123µs
# spent 89µs (55+34) within RTP::Webmerge::Compile::JS::BEGIN@10 which was called: # once (55µs+34µs) by main::BEGIN@40 at line 10
use warnings;
# spent 89µs making 1 call to RTP::Webmerge::Compile::JS::BEGIN@10 # spent 34µs making 1 call to warnings::import
11
12###################################################################################################
13
14# define our version string
151154µs124µs
# spent 24µs within RTP::Webmerge::Compile::JS::BEGIN@15 which was called: # once (24µs+0s) by main::BEGIN@40 at line 15
BEGIN { $RTP::Webmerge::Compile::JS::VERSION = "0.70" }
# spent 24µs making 1 call to RTP::Webmerge::Compile::JS::BEGIN@15
16
17# load exporter and inherit from it
183392µs278µs
# spent 54µs within RTP::Webmerge::Compile::JS::BEGIN@18.27 which was called: # once (54µs+0s) by main::BEGIN@40 at line 18 # spent 24µs within RTP::Webmerge::Compile::JS::BEGIN@18 which was called: # once (24µs+0s) by main::BEGIN@40 at line 18
BEGIN { use Exporter qw(); our @ISA = qw(Exporter) }
# spent 54µs making 1 call to RTP::Webmerge::Compile::JS::BEGIN@18.27 # spent 24µs making 1 call to RTP::Webmerge::Compile::JS::BEGIN@18
19
20# define our functions to be exported
211164µs129µs
# spent 29µs within RTP::Webmerge::Compile::JS::BEGIN@21 which was called: # once (29µs+0s) by main::BEGIN@40 at line 21
BEGIN { our @EXPORT = qw(compileJS); }
# spent 29µs making 1 call to RTP::Webmerge::Compile::JS::BEGIN@21
22
23###################################################################################################
24
25# run3 to get stdout and stderr
262730µs2138ms
# spent 138ms (14.9+123) within RTP::Webmerge::Compile::JS::BEGIN@26 which was called: # once (14.9ms+123ms) by main::BEGIN@40 at line 26
use IPC::Run3 qw(run3);
# spent 138ms making 1 call to RTP::Webmerge::Compile::JS::BEGIN@26 # spent 240µs making 1 call to Exporter::import
27
28# run3 to get stdout and stderr
2921.24ms21.25ms
# spent 658µs (63+595) within RTP::Webmerge::Compile::JS::BEGIN@29 which was called: # once (63µs+595µs) by main::BEGIN@40 at line 29
use RTP::Webmerge::Path qw(EOD $extroot check_path);
# spent 658µs making 1 call to RTP::Webmerge::Compile::JS::BEGIN@29 # spent 595µs making 1 call to Exporter::import
30
31###################################################################################################
32
33# compile js via google closure compiler
34#**************************************************************************************************
35sub compileJS
36{
37
38 # get input variables
39 my ($content, $config) = @_;
40
41 # make these configurable again
42 my $java_bin = '/usr/bin/java';
43
44 # hotfix for windows operating system
45 # all windows (even x64) report MSWin32!
46 $java_bin = "java" if ($^O eq "MSWin32");
47
48 # if java home is given we will force to use t
49 if (exists $ENV{'JAVA_HOME'} && defined $ENV{'JAVA_HOME'})
50 { $java_bin = join(EOD, $ENV{'JAVA_HOME'}, 'bin', 'java'); }
51
52 # create the command to execute the closure compiler
53 my $command = '"' . $java_bin . '" -jar ' .
54 # reference the closure compiler relative from extension
55 '"' . check_path('{EXT}/scripts/google/closure/compiler.jar') . '"' .
56 # use quiet warning level and safe compilation options
57 ' --warning_level QUIET --compilation_level SIMPLE_OPTIMIZATIONS';
58
59 # I should only listen for my own children
60 # IPC::Run3 will spawn it's own children
61 local $SIG{CHLD} = undef;
62
63 # now call run3 to compile the javascript code
64 my $rv = run3($command, \ $content, \ my $compiled, \ my $err);
65
66 # print content to console if we have errors
67 # this should only ever print error messages
68 print $compiled if $err || $? || $rv != 1;
69
70 # check if there was any error given by closure compiler
71 die "closure compiler had an error, aborting\n$err", "\n" if $err;
72
73 # test if ipc run3 returned success
74 die "closure compiler exited unexpectedly (code $?)", "\n" if $?;
75
76 # test if ipc run3 returned success
77 die "could not run closure compiler, aborting", "\n" if $rv != 1;
78
79 # return compiled
80 return $compiled;
81
82}
83# EO sub compileJS
84
85###################################################################################################
86###################################################################################################
87114µs1;