• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 #include "cs_config.h"
3 #include <unistd.h>
4 #include "util/neo_misc.h"
5 #include "util/neo_hdf.h"
6 #include "util/neo_rand.h"
7 #include "util/neo_files.h"
8 
main(int argc,char * argv[])9 int main(int argc, char *argv[])
10 {
11   NEOERR *err;
12   HDF *hdf;
13   int x;
14   double tstart = 0;
15   double tend = 0;
16   char *file;
17   int reps = 1000;
18   char *s = NULL;
19 
20   if (argc > 1)
21     file = argv[1];
22   else
23     file = "test.hdf";
24 
25   if (argc > 2)
26     reps = atoi(argv[2]);
27 
28   err = hdf_init(&hdf);
29   if (err != STATUS_OK)
30   {
31     nerr_log_error(err);
32     return -1;
33   }
34 
35   tstart = ne_timef();
36 
37   for (x = 0; x < reps; x++)
38   {
39     err = hdf_read_file(hdf, file);
40     if (err != STATUS_OK)
41     {
42       nerr_log_error(err);
43       return -1;
44     }
45   }
46   tend = ne_timef();
47   ne_warn("hdf_read_file test finished in %5.3fs, %5.3fs/rep", tend - tstart, (tend-tstart) / reps);
48 
49   tstart = ne_timef();
50 
51   for (x = 0; x < reps; x++)
52   {
53     err = ne_load_file(file, &s);
54     if (err != STATUS_OK)
55     {
56       nerr_log_error(err);
57       return -1;
58     }
59     err = hdf_read_string(hdf, s);
60     if (err != STATUS_OK)
61     {
62       nerr_log_error(err);
63       return -1;
64     }
65     free(s);
66   }
67   tend = ne_timef();
68   ne_warn("load/hdf_read_string test finished in %5.3fs, %5.3fs/rep", tend - tstart, (tend-tstart) / reps);
69 
70 
71   err = ne_load_file(file, &s);
72   if (err != STATUS_OK)
73   {
74     nerr_log_error(err);
75     return -1;
76   }
77   tstart = ne_timef();
78   for (x = 0; x < reps; x++)
79   {
80     err = hdf_read_string(hdf, s);
81     if (err != STATUS_OK)
82     {
83       nerr_log_error(err);
84       return -1;
85     }
86   }
87   tend = ne_timef();
88   free(s);
89   ne_warn("hdf_read_string test finished in %5.3fs, %5.3fs/rep", tend - tstart, (tend-tstart) / reps);
90   /* hdf_dump(hdf, NULL);  */
91 
92   hdf_destroy(&hdf);
93 
94   return 0;
95 }
96