summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0779dfc)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
*
* t/genzipf zipf 1.2 100000 20
*
*
* t/genzipf zipf 1.2 100000 20
*
+ * Only the distribution type (zipf or pareto) and spread input need
+ * to be given, if not given defaults are used.
+ *
*/
#include <stdio.h>
#include <stdlib.h>
*/
#include <stdio.h>
#include <stdlib.h>
+#define DEF_NR 1000000
+#define DEF_NR_OUTPUT 23
+
static int val_cmp(const void *p1, const void *p2)
{
const unsigned long *v1 = p1;
static int val_cmp(const void *p1, const void *p2)
{
const unsigned long *v1 = p1;
unsigned long nranges, output_nranges;
unsigned long *vals;
unsigned long i, j, nr_vals, cur_vals, max_val, interval;
unsigned long nranges, output_nranges;
unsigned long *vals;
unsigned long i, j, nr_vals, cur_vals, max_val, interval;
+ double *output, perc, perc_i;
struct zipf_state zs;
int use_zipf;
double val;
struct zipf_state zs;
int use_zipf;
double val;
printf("%s: {zipf,pareto} val values [output ranges]\n", argv[0]);
return 1;
}
printf("%s: {zipf,pareto} val values [output ranges]\n", argv[0]);
return 1;
}
- nranges = strtoul(argv[3], NULL, 10);
- if (argc == 5)
+
+ nranges = DEF_NR;
+ output_nranges = DEF_NR_OUTPUT;
+
+ if (argc >= 4)
+ nranges = strtoul(argv[3], NULL, 10);
+ if (argc >= 5)
output_nranges = strtoul(argv[4], NULL, 10);
output_nranges = strtoul(argv[4], NULL, 10);
- else
- output_nranges = nranges;
- printf("Generating %s distribution with %f input and %lu ranges\n", use_zipf ? "zipf" : "pareto", val, nranges);
- getchar();
+ printf("Generating %s distribution with %f input and %lu ranges.\n", use_zipf ? "zipf" : "pareto", val, nranges);
if (use_zipf)
zipf_init(&zs, nranges, val);
if (use_zipf)
zipf_init(&zs, nranges, val);
- for (i = 0; i < j; i++)
- printf("%.2f%%\n", output[i]);
+ perc_i = 100.0 / (double) output_nranges;
+ perc = 0.0;
+ for (i = 0; i < j; i++) {
+ printf("%6.2f%% -> %6.2f%%:\t%6.2f%%\n", perc, perc + perc_i, output[i]);
+ perc += perc_i;
+ }
free(output);
free(vals);
free(output);
free(vals);