* The last row was not displayed
* some useless variables were used
* the calculation for the output table missed a few events, so the sum of 'No Hits' column was wrong
* Wrong sample in genzipf.c header, used old style arguments
* the help message for -o options was misleading.
* useless define of DEF_NR.
* default of default row number to a more common value of 20,
instead of 23.
* what an access pattern would look like.
*
* For instance, the following would generate a zipf distribution
* what an access pattern would look like.
*
* For instance, the following would generate a zipf distribution
- * with theta 1.2, using 100,000 values and split the reporting into
+ * with theta 1.2, using 262144 (1 GB / 4096) values and split the reporting into
- * t/genzipf zipf 1.2 100000 20
+ * ./t/fio-genzipf -t zipf -i 1.2 -g 1 -b 4096 -o 20
*
* Only the distribution type (zipf or pareto) and spread input need
* to be given, if not given defaults are used.
*
* Only the distribution type (zipf or pareto) and spread input need
* to be given, if not given defaults are used.
#include "../flist.h"
#include "../hash.h"
#include "../flist.h"
#include "../hash.h"
-#define DEF_NR 1000000
-#define DEF_NR_OUTPUT 23
+#define DEF_NR_OUTPUT 20
struct node {
struct flist_head list;
struct node {
struct flist_head list;
printf("\t-i\tDistribution algorithm input (zipf theta or pareto power)\n");
printf("\t-b\tBlock size of a given range (in bytes)\n");
printf("\t-g\tSize of data set (in gigabytes)\n");
printf("\t-i\tDistribution algorithm input (zipf theta or pareto power)\n");
printf("\t-b\tBlock size of a given range (in bytes)\n");
printf("\t-g\tSize of data set (in gigabytes)\n");
- printf("\t-o\tNumber of output columns\n");
+ printf("\t-o\tNumber of output rows\n");
printf("\t-c\tOutput ranges in CSV format\n");
}
printf("\t-c\tOutput ranges in CSV format\n");
}
int main(int argc, char *argv[])
{
unsigned long offset;
int main(int argc, char *argv[])
{
unsigned long offset;
- unsigned long i, j, k, nr_vals, cur_vals, interval, total_vals, nnodes;
+ unsigned long i, j, k, nr_vals, cur_vals, interval_step, next_interval, total_vals, nnodes;
unsigned long long nranges;
struct output_sum *output_sums;
struct node *nodes;
unsigned long long nranges;
struct output_sum *output_sums;
struct node *nodes;
nodes = malloc(nranges * sizeof(struct node));
nodes = malloc(nranges * sizeof(struct node));
- for (nr_vals = i = j = 0; i < nranges; i++) {
+ for (i = j = 0; i < nranges; i++) {
struct node *n;
if (dist_type == TYPE_ZIPF)
struct node *n;
if (dist_type == TYPE_ZIPF)
}
qsort(nodes, j, sizeof(struct node), node_cmp);
}
qsort(nodes, j, sizeof(struct node), node_cmp);
if (output_csv) {
printf("rank, count\n");
if (output_csv) {
printf("rank, count\n");
- for (k = 0; k < nnodes; k++)
+ for (k = 0; k < nnodes; k++) {
printf("%lu, %lu\n", k, nodes[k].hits);
printf("%lu, %lu\n", k, nodes[k].hits);
- interval = (nr_vals + output_nranges - 1) / output_nranges;
-
+ unsigned long blocks = percentage * nranges / 100;
+ double hit_percent_sum = 0;
+ unsigned long long hit_sum = 0;
+ interval_step = (nr_vals - 1) / output_nranges + 1;
+ next_interval = interval_step;
output_sums = malloc(output_nranges * sizeof(struct output_sum));
for (i = 0; i < output_nranges; i++) {
output_sums[i].output = 0.0;
output_sums = malloc(output_nranges * sizeof(struct output_sum));
for (i = 0; i < output_nranges; i++) {
output_sums[i].output = 0.0;
- output_sums[i].nranges = 1;
+ output_sums[i].nranges = 0;
- total_vals = i = j = cur_vals = 0;
+ j = total_vals = cur_vals = 0;
for (k = 0; k < nnodes; k++) {
struct output_sum *os = &output_sums[j];
struct node *node = &nodes[k];
for (k = 0; k < nnodes; k++) {
struct output_sum *os = &output_sums[j];
struct node *node = &nodes[k];
-
- if (i >= interval) {
- os->output =
- (double)(cur_vals + 1) / (double)nranges;
+ cur_vals += node->hits;
+ total_vals += node->hits;
+ os->nranges += node->hits;
+ if (k == (next_interval) -1 || k == (nnodes - 1)) {
+ os->output = (double)(cur_vals) / (double)nranges;
+ cur_vals = 0;
+ next_interval += interval_step;
- cur_vals = node->hits;
- interval +=
- (nr_vals + output_nranges -
- 1) / output_nranges;
- } else {
- cur_vals += node->hits;
- os->nranges += node->hits;
- i++;
- total_vals += node->hits;
-
- unsigned long blocks =
- percentage * nranges / 100;
-
if (total_vals >= blocks) {
if (total_vals >= blocks) {
- double cs =
- i * block_size / (1024 * 1024);
+ double cs = k * block_size / (1024 * 1024);
char p = 'M';
if (cs > 1024.0) {
char p = 'M';
if (cs > 1024.0) {
perc_i = 100.0 / (double)output_nranges;
perc = 0.0;
perc_i = 100.0 / (double)output_nranges;
perc = 0.0;
- printf("\n Rows Hits No Hits Size\n");
+ printf("\n Rows Hits %% No Hits Size\n");
printf("--------------------------------------------------------\n");
printf("--------------------------------------------------------\n");
- for (i = 0; i < j; i++) {
+ for (i = 0; i < output_nranges; i++) {
struct output_sum *os = &output_sums[i];
double gb = (double)os->nranges * block_size / 1024.0;
char p = 'K';
struct output_sum *os = &output_sums[i];
double gb = (double)os->nranges * block_size / 1024.0;
char p = 'K';
+ hit_percent_sum += os->output;
+ hit_sum += os->nranges;
printf("%s %6.2f%%\t%6.2f%%\t\t%8u\t%6.2f%c\n",
i ? "|->" : "Top", perc, os->output, os->nranges,
gb, p);
}
printf("%s %6.2f%%\t%6.2f%%\t\t%8u\t%6.2f%c\n",
i ? "|->" : "Top", perc, os->output, os->nranges,
gb, p);
}
+ printf("--------------------------------------------------------\n");
+ printf("Total\t\t%6.2f%%\t\t%8llu\n", hit_percent_sum, hit_sum);