conf t
line con 0
logging synchronous
line vty 0 4
transport input telnet
logging synchronous
login
int vl1
ip address 192.16.1.x 255.255.255.0
no shutroot@dalun-XPS-13-9343:/var/lib/docker/volumes/test-compile/_data/pi# /usr/bin/time -v ./app PI = 3.141708 Command being timed: "./app" User time (seconds): 19.33 System time (seconds): 0.01 Percent of CPU this job got: 99% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:19.44 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes): 692 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 0 Minor (reclaiming a frame) page faults: 30 Voluntary context switches: 1 Involuntary context switches: 1718 Swaps: 0 File system inputs: 0 File system outputs: 0 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0 root@dalun-XPS-13-9343:/var/lib/docker/volumes/test-compile/_data/pi# /usr/bin/time -v ./app PI = 3.141708 Command being timed: "./app" User time (seconds): 22.41 System time (seconds): 0.01 Percent of CPU this job got: 99% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:22.48 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes): 696 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 0 Minor (reclaiming a frame) page faults: 31 Voluntary context switches: 1 Involuntary context switches: 1149 Swaps: 0 File system inputs: 0 File system outputs: 0 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
double pi(int n) {
srand(5);
int count = 0;
double x, y;
for (int i = 0; i < n; ++i) {
x = (double) rand() / RAND_MAX;
y = (double) rand() / RAND_MAX;
if (x * x + y * y <= 1) ++count;
}
return (double) count / n * 4;
}
int main() {
double result = pi(1e9);
printf("PI = %f\n", result);
}/usr/bin/time -v ./tmp PI = 3.141708 Command being timed: "./tmp" User time (seconds): 15.56 System time (seconds): 0.00 Percent of CPU this job got: 99% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:15.56 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes): 696 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 0 Minor (reclaiming a frame) page faults: 31 Voluntary context switches: 1 Involuntary context switches: 7 Swaps: 0 File system inputs: 0 File system outputs: 0 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0
bb@test:~$ for i in {0..9}; do time ./tmp; done 2>&1 | grep real
real 0m3.329s
real 0m3.348s
real 0m3.306s
real 0m3.317s
real 0m3.316s
real 0m3.304s
real 0m3.306s
real 0m3.324s
real 0m3.327s
real 0m3.366s