1 /* chrono - demo of GRAS benchmarking features */
3 /* Copyright (c) 2005 Martin Quinson, Arnaud Legrand. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
11 XBT_LOG_NEW_DEFAULT_CATEGORY(Chrono, "Messages specific to this example");
14 /* Function prototypes */
15 int multiplier(int argc, char *argv[]);
17 int multiplier(int argc, char *argv[])
25 gras_init(&argc, argv);
27 A = malloc(n * n * sizeof(double));
28 B = malloc(n * n * sizeof(double));
29 C = malloc(n * n * sizeof(double));
31 start = now = gras_os_time();
33 INFO1("Begin matrix multiplication loop (time: %g)", start);
35 for (l = 0; l < 4; l++) {
37 GRAS_BENCH_ONCE_RUN_ONCE_BEGIN();
38 for (i = 0; i < n; i++)
39 for (j = 0; j < n; j++) {
45 for (i = 0; i < n; i++)
46 for (j = 0; j < n; j++)
47 for (k = 0; k < n; k++)
48 C[i * n + j] += A[i * n + k] * B[k * n + j];
50 GRAS_BENCH_ONCE_RUN_ONCE_END();
51 now = gras_os_time() - now;
52 INFO2("Iteration %d : %g ", l, now);
55 now = gras_os_time() - start;
56 INFO2("End matrix multiplication loop (time: %g; Duration: %g)",
59 start = now = gras_os_time();
60 INFO1("Begin malloc loop (time: %g)", start);
61 for (l = 0; l < 4; l++) {
63 GRAS_BENCH_ONCE_RUN_ONCE_BEGIN();
65 A = malloc(n * n * sizeof(double));
66 GRAS_BENCH_ONCE_RUN_ONCE_END();
67 now = gras_os_time() - now;
68 INFO2("Iteration %d : %g ", l, now);
71 start = now = gras_os_time();
72 INFO1("Begin integer incrementation loop (time: %g)", start);
73 for (l = 0; l < 4; l++) {
74 GRAS_BENCH_ONCE_RUN_ONCE_BEGIN();
76 GRAS_BENCH_ONCE_RUN_ONCE_END();