Now I was also able to see the 354.7µs of Execution Time:
$ date +"%s.%N" ; target/release/text-sanitizer_v2 -i < lanzarote-com_de-ausfluge.html >/dev/null ; date +"%s.%N"
1589793780.372181577
Input time: 43.534µs
Parse time: 203.554µs
Total time: 354.7µs
1589793780.377126057
$ echo "scale=3; (80.377126057-80.372181577)*1000*1000"|bc -l
4944.480000000
$ echo "scale=3; 4944.48-354.7"|bc -l
4589.78
But this opens a question about a Time Gap of 4,6ms before and after the main()
Function of Rust
So I printed a Timestamp at the main()
Function entrance and includes some profiling measurements
As it can be seen in my Updated Version:
$ date +"%s.%N" ; target/release/text-sanitizer -i -p < lanzarote-com_de-ausfluge.html >/dev/null ; date +"%s.%N"
1589793005.975659287
0: 1589793005.978346173s
1: 1589793005.978429231s
Input time: 73.079µs
2: 1589793005.978545255s
3: 1589793005.978575797s
Parse time: 440.709µs
4: 1589793005.979051209s
Total time: 752.843µs
5: 1589793005.979129697s
1589793005.980647882
$ echo "scale=3; 05.980647882-05.975659287"|bc -l
.004988595
$ echo "scale=3; 05.979129697-05.978346173"|bc -l
.000783524
On Entering the main()
Function it will print the Timestamp:
0: 1589793005.978346173s
And on Leaving it will print:
5: 1589793005.979129697s
So before printing the first Timestamp there is a Time Gap of 2.7ms:
$ echo "scale=3; 05.978346173-05.975659287"|bc -l
.002686886
Is this the time the Operating System needs to "fork" the Executable or is this the Rust Start-Up Sequence?
With the -i
Parameter and the -p
Parameter I was able to exclude external Helper Commands and feed the Test Data directly into the STDIN of the Process.
So I took the strace
Activity Log to see that the Application is doing before printing the first line.
$ strace -ttt -o strace_txt-san-rs_2020-05-18-3.log target/release/text-sanitizer -i -p < lanzarote-com_de-ausfluge.html >/dev/null
0: 1589795630.000705955s
1: 1589795630.000997402s
Input time: 427.296µs
2: 1589795630.001685844s
3: 1589795630.001953786s
Parse time: 778.675µs
4: 1589795630.002967769s
Total time: 2.527188ms
5: 1589795630.003486638s
In Summary before to be able to measure anything or print the first line Rust needs to load its External Dependencies:
$ cat strace_txt-san-rs_2020-05-18-3.log|grep -niE "open(.*\.so.*)"
5:1589795629.996421 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
9:1589795629.996613 open("/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
16:1589795629.996920 open("/lib64/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
23:1589795629.997205 open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
32:1589795629.997744 open("/lib64/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
39:1589795629.998057 open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
In total 84 Operations:
$ cat strace_txt-san-rs_2020-05-18-3.log|grep -ni "write(2, \"0: \""
86:1589795630.000725 write(2, "0: ", 3) = 3
So all this time is part of the Rust Start-Up Sequence and it is an important aspect of the User Experience.