我想知道我的Erlang / OTP发布启动脚本(.script和.boot文件)运行的时间有多长。编程Erlang第2版,附录3表示加载OTP需要一秒钟,加载67个模块并启动25个进程。这用作在没有OTP的情况下运行VM的动机。我想在我的设置中量化OTP和模块的加载时间。这样做有简单的方法吗?
答案 0 :(得分:3)
如果通过-init_debug
管道调试打印,ts
选项会提供一些信息。这是一个例子。每个时间戳都是自上一行打印以来的秒数。
$ erl -init_debug | ts -i '%.s'
0.008446 {progress,preloaded}
0.001501 {progress,kernel_load_completed}
0.000576 {progress,modules_loaded}
0.000352 {start,heart}
0.001627 {start,error_logger}
0.011464 {start,application_controller}
0.024965 {progress,init_kernel_started}
0.000147 {apply,{application,load,[{application,stdlib,[{description,"ERTS CXC 138 10"},{vsn,"1.19.4"},{id,[]},{modules,[array,base64,beam_lib,binary,c,calendar,dets,dets_server,dets_sup,dets_utils,dets_v8,dets_v9,dict,digraph,digraph_utils,edlin,edlin_expand,epp,eval_bits,erl_bits,erl_compile,erl_eval,erl_expand_records,erl_internal,erl_lint,erl_parse,erl_posix_msg,erl_pp,erl_scan,erl_tar,error_logger_file_h,error_logger_tty_h,escript,ets,file_sorter,filelib,filename,gb_trees,gb_sets,gen,gen_event,gen_fsm,gen_server,io,io_lib,io_lib_format,io_lib_fread,io_lib_pretty,lib,lists,log_mf_h,math,ms_transform,orddict,ordsets,otp_internal,pg,pool,proc_lib,proplists,qlc,qlc_pt,queue,random,re,sets,shell,shell_default,slave,sofs,string,supervisor,supervisor_bridge,sys,timer,unicode,win32reg,zip]},{registered,[timer_server,rsh_starter,take_over_monitor,pool_master,dets]},{applications,[kernel]},{included_applications,[]},{env,[]},{maxT,infinity},{maxP,infinity}]}]}}
0.004207 {progress,applications_loaded}
0.000136 {apply,{application,start_boot,[kernel,permanent]}}
0.302955 {apply,{application,start_boot,[stdlib,permanent]}}
0.000171 {apply,{c,erlangrc,[]}}
0.021488 {progress,started}
0.051776 Eshell V5.10.4 (abort with ^G)
在这个例子中,application:start_boot(kernel, permanent)
看起来很慢,因为大约需要300毫秒。