diff options
| -rw-r--r-- | fs_demo.c | 31 |
1 files changed, 17 insertions, 14 deletions
@@ -1,4 +1,5 @@ -#include "fieldstat/fieldstat_easy.h" +#include <fieldstat/fieldstat_easy.h> + #include <pthread.h> #include <stdlib.h> #include <unistd.h> @@ -24,9 +25,10 @@ void *thread_function(void *arg) int hdr_id = td->hdr_id; while (1) { - fieldstat_easy_counter_incrby(fse, thread_id, counter_id, td->tag1, 1, 100); + fieldstat_easy_counter_incrby(fse, thread_id, counter_id, td->tag1, 1, 1); fieldstat_easy_counter_incrby(fse, thread_id, counter_id, td->tag2, 1, 2); - fieldstat_easy_histogram_record(fse, thread_id, hdr_id, td->tag1, 1, rand() % 10000); + sleep(1); + // fieldstat_easy_histogram_record(fse, thread_id, hdr_id, td->tag1, 1, rand() % 10000); } return NULL; } @@ -41,18 +43,19 @@ int main() tmptag.value_longlong = 1; global_tags[0] = tmptag; - struct field tag1 = {"direction", FIELD_VALUE_INTEGER, "incoming"}; - struct field tag2 = {"direction", FIELD_VALUE_INTEGER, "outgoing"}; + struct field tag1 = {"direction", FIELD_VALUE_CSTRING, {.value_str = "incoming"}}; + struct field tag2 = {"direction", FIELD_VALUE_CSTRING, {.value_str = "outgoing"}}; - struct fieldstat_easy *fse = fieldstat_easy_new(N_THREADS, NULL, global_tags, 1); - int counter_id = fieldstat_easy_register_counter(fse, "incoming bytes"); - int hdr_id = fieldstat_easy_register_histogram( - fse, "delay", - 1, // min trackable value, no less than 1. The value less than this value will still be recorded, with an - // unpromising precision. - 10000, // max trackable value, the value larger than this value will be recorded as the max value. - 1); // precision, value less than 10 ^ precision will be recorded keeping exact precision. The larger recorded - // value is, the less precise of its count is. + struct fieldstat_easy *fse = fieldstat_easy_new(N_THREADS, "n23", global_tags, 1); + int counter_id = fieldstat_easy_register_counter(fse, "bytes"); + int hdr_id = 0; + // int hdr_id = fieldstat_easy_register_histogram( + // fse, "delay", + // 1, // min trackable value, no less than 1. The value less than this value will still be recorded, with an + // // unpromising precision. + // 10000, // max trackable value, the value larger than this value will be recorded as the max value. + // 1); // precision, value less than 10 ^ precision will be recorded keeping exact precision. The larger recorded + // // value is, the less precise of its count is. int output_interval_seconds = 1; fieldstat_easy_enable_auto_output(fse, FILENAME, output_interval_seconds); // FILENAME is the same as the one you set in python. |
