Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

137
Vistas
time command shows user time greater than real time

I have more or less the same question as

linux time command resulting real is less than user

and

user time larger than real time

but can't post a comment on those questions.

When I run the non-multi-threaded program given below, I occasionally get user time greater than real time with both /usr/bin/time and bash's builtin time. I don't see anything that might use a different core. Is rand() somehow the culprit? How? Thanks!

#include <stdio.h>
#include <stdlib.h>

#define N 100
#define MM_MAX 50000

int
main(int ac, char **av)
{
    unsigned int i, j, k, n;
    int A[N][N], B[N][N], C[N][N];

    if (ac != 2) {
        fprintf(stderr, "Usage: matmul <seed>");
        exit(1);
    }
    srand((unsigned int) atoi(av[1]));

    for (n = 0; n < atoi(av[1]); n++) {
        for (i = 0; i < N; i++) {
            for (j = 0; j < N; j++) {
                A[i][j] = rand() % MM_MAX;
                B[i][j] = rand() % MM_MAX;
            }
        }
        for (i = 0; i < N; i++) {
            for (j = 0; j < N; j++) {
                C[i][j] = 0;
                for (k = 0; k < N; k++) {
                    C[i][j] += A[i][k] * B[k][j];
                }
                printf("%7d ", C[i][j]);
            }
            putchar('\n');
        }
    }

    return 0;
}
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda