@@ -375,7 +375,10 @@ exports.main = function main(argv, options, callback) {
375
375
let transform = transforms [ i ] ;
376
376
if ( typeof transform [ name ] === "function" ) {
377
377
try {
378
- transform [ name ] ( ...args ) ;
378
+ stats . transformCount ++ ;
379
+ stats . transfromTime += measure ( ( ) => {
380
+ transform [ name ] ( ...args ) ;
381
+ } ) ;
379
382
} catch ( e ) {
380
383
return e ;
381
384
}
@@ -605,29 +608,11 @@ exports.main = function main(argv, options, callback) {
605
608
return callback ( null ) ;
606
609
}
607
610
608
- // Set up optimization levels
609
- var optimizeLevel = 0 ;
610
- var shrinkLevel = 0 ;
611
- if ( args . optimize ) {
612
- optimizeLevel = exports . defaultOptimizeLevel ;
613
- shrinkLevel = exports . defaultShrinkLevel ;
614
- }
615
- if ( typeof args . optimizeLevel === "number" ) {
616
- optimizeLevel = args . optimizeLevel ;
617
- }
618
- if ( typeof args . shrinkLevel === "number" ) {
619
- shrinkLevel = args . shrinkLevel ;
620
- }
621
- optimizeLevel = Math . min ( Math . max ( optimizeLevel , 0 ) , 3 ) ;
622
- shrinkLevel = Math . min ( Math . max ( shrinkLevel , 0 ) , 2 ) ;
623
-
624
- try {
625
- stats . compileTime += measure ( ( ) => {
626
- assemblyscript . initializeProgram ( program , compilerOptions ) ;
627
- } ) ;
628
- } catch ( e ) {
629
- return callback ( e ) ;
630
- }
611
+ // Pre-emptively initialize the program
612
+ stats . initializeCount ++ ;
613
+ stats . initializeTime += measure ( ( ) => {
614
+ assemblyscript . initializeProgram ( program ) ;
615
+ } ) ;
631
616
632
617
// Call afterInitialize transform hook
633
618
{
@@ -637,13 +622,9 @@ exports.main = function main(argv, options, callback) {
637
622
638
623
var module ;
639
624
stats . compileCount ++ ;
640
- try {
641
- stats . compileTime += measure ( ( ) => {
642
- module = assemblyscript . compile ( program ) ;
643
- } ) ;
644
- } catch ( e ) {
645
- return callback ( e ) ;
646
- }
625
+ stats . compileTime += measure ( ( ) => {
626
+ module = assemblyscript . compile ( program ) ;
627
+ } ) ;
647
628
var numErrors = checkDiagnostics ( program , stderr ) ;
648
629
if ( numErrors ) {
649
630
if ( module ) module . dispose ( ) ;
@@ -907,6 +888,7 @@ exports.main = function main(argv, options, callback) {
907
888
function listFilesNode ( dirname , baseDir ) {
908
889
var files ;
909
890
try {
891
+ stats . readCount ++ ;
910
892
stats . readTime += measure ( ( ) => {
911
893
files = fs . readdirSync ( path . join ( baseDir , dirname ) ) . filter ( file => extension . re_except_d . test ( file ) )
912
894
} ) ;
@@ -958,14 +940,18 @@ function createStats() {
958
940
writeCount : 0 ,
959
941
parseTime : 0 ,
960
942
parseCount : 0 ,
943
+ initializeTime : 0 ,
944
+ initializeCount : 0 ,
961
945
compileTime : 0 ,
962
946
compileCount : 0 ,
963
947
emitTime : 0 ,
964
948
emitCount : 0 ,
965
949
validateTime : 0 ,
966
950
validateCount : 0 ,
967
951
optimizeTime : 0 ,
968
- optimizeCount : 0
952
+ optimizeCount : 0 ,
953
+ transformTime : 0 ,
954
+ transformCount : 0
969
955
} ;
970
956
}
971
957
@@ -983,26 +969,33 @@ function measure(fn) {
983
969
984
970
exports . measure = measure ;
985
971
972
+ function pad ( str , len ) {
973
+ while ( str . length < len ) str = " " + str ;
974
+ return str ;
975
+ }
976
+
986
977
/** Formats a high resolution time to a human readable string. */
987
978
function formatTime ( time ) {
988
- return time ? ( time / 1e6 ) . toFixed ( 3 ) + " ms" : "N/A " ;
979
+ return time ? ( time / 1e6 ) . toFixed ( 3 ) + " ms" : "n/a " ;
989
980
}
990
981
991
982
exports . formatTime = formatTime ;
992
983
993
984
/** Formats and prints out the contents of a set of stats. */
994
985
function printStats ( stats , output ) {
995
986
function format ( time , count ) {
996
- return formatTime ( time ) ;
987
+ return pad ( formatTime ( time ) , 12 ) + " n=" + count ;
997
988
}
998
989
( output || process . stdout ) . write ( [
999
- "I/O Read : " + format ( stats . readTime , stats . readCount ) ,
1000
- "I/O Write : " + format ( stats . writeTime , stats . writeCount ) ,
1001
- "Parse : " + format ( stats . parseTime , stats . parseCount ) ,
1002
- "Compile : " + format ( stats . compileTime , stats . compileCount ) ,
1003
- "Emit : " + format ( stats . emitTime , stats . emitCount ) ,
1004
- "Validate : " + format ( stats . validateTime , stats . validateCount ) ,
1005
- "Optimize : " + format ( stats . optimizeTime , stats . optimizeCount )
990
+ "I/O Read : " + format ( stats . readTime , stats . readCount ) ,
991
+ "I/O Write : " + format ( stats . writeTime , stats . writeCount ) ,
992
+ "Parse : " + format ( stats . parseTime , stats . parseCount ) ,
993
+ "Initialize : " + format ( stats . initializeTime , stats . initializeCount ) ,
994
+ "Compile : " + format ( stats . compileTime , stats . compileCount ) ,
995
+ "Emit : " + format ( stats . emitTime , stats . emitCount ) ,
996
+ "Validate : " + format ( stats . validateTime , stats . validateCount ) ,
997
+ "Optimize : " + format ( stats . optimizeTime , stats . optimizeCount ) ,
998
+ "Transform : " + format ( stats . transformTime , stats . transformCount )
1006
999
] . join ( EOL ) + EOL ) ;
1007
1000
}
1008
1001
0 commit comments