unix - Qu'est-ce que 39;réalisé#39, 39;utilisateur marqué#39 et 39;sysdent#39 signifie dans la sortie du temps(1)

Mots clés : unixtimebenchmarking

meilleur 2 Réponses unix - Qu'est-ce que 39;réalisé#39, 39;utilisateur marqué#39 et 39;sysdent#39 signifie dans la sortie du temps(1)

vote vote

90

real    1m47.363s user    2m41.318s sys     0m4.013s 
vote vote

83

gcc -ggdb3 -o main.out -pthread -std=c99 -pedantic-errors -Wall -Wextra main.c time ./main.out 
#define _XOPEN_SOURCE 700 #include <stdlib.h> #include <unistd.h>  int main(void) {     sleep(1);     return EXIT_SUCCESS; } 
real    0m1.003s user    0m0.001s sys     0m0.003s 
#include <stdio.h> #include <stdlib.h>  int main(void) {     printf("%c\n", getchar());     return EXIT_SUCCESS; } 
real    0m1.003s user    0m0.001s sys     0m0.003s 
#define _XOPEN_SOURCE 700 #include <assert.h> #include <inttypes.h> #include <pthread.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h>  uint64_t niters;  void* my_thread(void *arg) {     uint64_t *argument, i, result;     argument = (uint64_t *)arg;     result = *argument;     for (i = 0; i < niters; ++i) {         result = (result * result) - (3 * result) + 1;     }     *argument = result;     return NULL; }  int main(int argc, char **argv) {     size_t nthreads;     pthread_t *threads;     uint64_t rc, i, *thread_args;      /* CLI args. */     if (argc > 1) {         niters = strtoll(argv[1], NULL, 0);     } else {         niters = 1000000000;     }     if (argc > 2) {         nthreads = strtoll(argv[2], NULL, 0);     } else {         nthreads = 1;     }     threads = malloc(nthreads * sizeof(*threads));     thread_args = malloc(nthreads * sizeof(*thread_args));      /* Create all threads */     for (i = 0; i < nthreads; ++i) {         thread_args[i] = i;         rc = pthread_create(             &threads[i],             NULL,             my_thread,             (void*)&thread_args[i]         );         assert(rc == 0);     }      /* Wait for all threads to complete */     for (i = 0; i < nthreads; ++i) {         rc = pthread_join(threads[i], NULL);         assert(rc == 0);         printf("%" PRIu64 " %" PRIu64 "\n", i, thread_args[i]);     }      free(threads);     free(thread_args);     return EXIT_SUCCESS; } 
dd if=/dev/urandom of=sendfile.in.tmp bs=1K count=10M 
#define _GNU_SOURCE #include <assert.h> #include <fcntl.h> #include <stdlib.h> #include <sys/sendfile.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h>  int main(int argc, char **argv) {     char *source_path, *dest_path;     int source, dest;     struct stat stat_source;     if (argc > 1) {         source_path = argv[1];     } else {         source_path = "sendfile.in.tmp";     }     if (argc > 2) {         dest_path = argv[2];     } else {         dest_path = "sendfile.out.tmp";     }     source = open(source_path, O_RDONLY);     assert(source != -1);     dest = open(dest_path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);     assert(dest != -1);     assert(fstat(source, &stat_source) != -1);     assert(sendfile(dest, source, 0, stat_source.st_size) != -1);     assert(close(source) != -1);     assert(close(dest) != -1);     return EXIT_SUCCESS; } 
real    0m2.175s user    0m0.001s sys     0m1.476s 
time ./sendfile.out sendfile.in1.tmp sendfile.out1.tmp & time ./sendfile.out sendfile.in2.tmp sendfile.out2.tmp & 
real    0m3.651s user    0m0.000s sys     0m1.516s  real    0m4.948s user    0m0.000s sys     0m1.562s 
type time 
time is a shell keyword 
git grep '"user\b' 
/usr/bin/time 
gcc -ggdb3 -o main.out -pthread -std=c99 -pedantic-errors -Wall -Wextra main.c time ./main.out 
#define _XOPEN_SOURCE 700 #include <stdlib.h> #include <unistd.h>  int main(void) {     sleep(1);     return EXIT_SUCCESS; } 
real    0m1.003s user    0m0.001s sys     0m0.003s 
#include <stdio.h> #include <stdlib.h>  int main(void) {     printf("%c\n", getchar());     return EXIT_SUCCESS; } 
real    0m1.003s user    0m0.001s sys     0m0.003s 
#define _XOPEN_SOURCE 700 #include <assert.h> #include <inttypes.h> #include <pthread.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h>  uint64_t niters;  void* my_thread(void *arg) {     uint64_t *argument, i, result;     argument = (uint64_t *)arg;     result = *argument;     for (i = 0; i < niters; ++i) {         result = (result * result) - (3 * result) + 1;     }     *argument = result;     return NULL; }  int main(int argc, char **argv) {     size_t nthreads;     pthread_t *threads;     uint64_t rc, i, *thread_args;      /* CLI args. */     if (argc > 1) {         niters = strtoll(argv[1], NULL, 0);     } else {         niters = 1000000000;     }     if (argc > 2) {         nthreads = strtoll(argv[2], NULL, 0);     } else {         nthreads = 1;     }     threads = malloc(nthreads * sizeof(*threads));     thread_args = malloc(nthreads * sizeof(*thread_args));      /* Create all threads */     for (i = 0; i < nthreads; ++i) {         thread_args[i] = i;         rc = pthread_create(             &threads[i],             NULL,             my_thread,             (void*)&thread_args[i]         );         assert(rc == 0);     }      /* Wait for all threads to complete */     for (i = 0; i < nthreads; ++i) {         rc = pthread_join(threads[i], NULL);         assert(rc == 0);         printf("%" PRIu64 " %" PRIu64 "\n", i, thread_args[i]);     }      free(threads);     free(thread_args);     return EXIT_SUCCESS; } 
dd if=/dev/urandom of=sendfile.in.tmp bs=1K count=10M 
#define _GNU_SOURCE #include <assert.h> #include <fcntl.h> #include <stdlib.h> #include <sys/sendfile.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h>  int main(int argc, char **argv) {     char *source_path, *dest_path;     int source, dest;     struct stat stat_source;     if (argc > 1) {         source_path = argv[1];     } else {         source_path = "sendfile.in.tmp";     }     if (argc > 2) {         dest_path = argv[2];     } else {         dest_path = "sendfile.out.tmp";     }     source = open(source_path, O_RDONLY);     assert(source != -1);     dest = open(dest_path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);     assert(dest != -1);     assert(fstat(source, &stat_source) != -1);     assert(sendfile(dest, source, 0, stat_source.st_size) != -1);     assert(close(source) != -1);     assert(close(dest) != -1);     return EXIT_SUCCESS; } 
real    0m2.175s user    0m0.001s sys     0m1.476s 
time ./sendfile.out sendfile.in1.tmp sendfile.out1.tmp & time ./sendfile.out sendfile.in2.tmp sendfile.out2.tmp & 
real    0m3.651s user    0m0.000s sys     0m1.516s  real    0m4.948s user    0m0.000s sys     0m1.562s 
type time 
time is a shell keyword 
git grep '"user\b' 
/usr/bin/time 

Questions similaires