How many times your TM (your personal Computer) can count upward, starts from 0, in a limited time (Assume for 1 Second)?
The main.exe
is an executable, source code was written in C++, that counts approximately 600 million times
in 1 second!
TM main counts 600000000 times in 1.0003 second!
Note: TM main runs in my personal computer. On the github server it runs slower, 400 Milion in the same time.
Note1: Machines are much stronger than us because they live in different time scale than us. 1 second in our world is perceived 10 nano second in the machines world!
$ g++ main.cpp -o main -pthread -std=c++14
$ ./main
Where, Input is main.cpp
, a source code file in c++ language.
graph TD;
Input-->Preprocessor ;
Preprocessor-->Compiler;
Compiler-->Assembler ;
Assembler-->Linker;
Linker-->Output ;
And Output is main
, a binary executable file.
main.cpp
$ ls -l main.cpp
size: 894
Written by "amirmasp".
Note2: counter.cpp code is embedded into main.cpp source code.
A Preprocessor function Transforms the source code main.cpp
into a preprocessed code main.i
.
$ g++ -E main.cpp > main.i
This file is much larger than the source code file.
$ ls -l main.i
size: 999555
A Compiler does Transform the preprocessed codemain.i
to an assembly code main.s
.
$ g++ -S main.cpp
$ ls -l main.s
size: 106544
$ g++ -C main.cpp
An Assembler generates a machine code a.out
given the assembly code main.s
.
Note3: the Object code == the machine code == binary code
Note4: In our experiment we use thread library, so use this command:
$ g++ -C main.cpp -pthread -std=c++14
$ ls -l a.out
size: 36464
The Linker links object files and libraries and generates the final executable file main
.
main
$ ls -l main
size: 36672
Note5: final executable file main
is larger than machine code a.out
. Because Linker added library codes with machine codes.