summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorchenzizhan <[email protected]>2023-12-18 10:36:10 +0800
committerchenzizhan <[email protected]>2023-12-18 10:36:10 +0800
commitc19b0d08be3ce70641c1c5707d3e67fa3c50c72e (patch)
tree79be6982308e69ccd35b905536dc0fe79edc47d9 /src
parenta3bd4934eb46e67d76489e2fec597e9cb30a84de (diff)
feat: fieldstat easy resetv4.4.4
Diffstat (limited to 'src')
-rw-r--r--src/fieldstat_easy.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/fieldstat_easy.c b/src/fieldstat_easy.c
index 61f17c5..a3fc148 100644
--- a/src/fieldstat_easy.c
+++ b/src/fieldstat_easy.c
@@ -256,9 +256,11 @@ struct fieldstat *merge_all_instance(struct fieldstat_easy *fse)
}
// add the outputted data
- pthread_spin_lock(&fse->outputting_lock);
- fieldstat_merge(dst, fse->accumulate);
- pthread_spin_unlock(&fse->outputting_lock);
+ if (fse->output_thread_running) {
+ pthread_spin_lock(&fse->outputting_lock);
+ fieldstat_merge(dst, fse->accumulate);
+ pthread_spin_unlock(&fse->outputting_lock);
+ }
return dst;
}
@@ -318,3 +320,24 @@ int fieldstat_easy_histogram_record(struct fieldstat_easy *fse, int thread_id, i
return ret;
}
+
+int fieldstat_easy_reset(struct fieldstat_easy *fse)
+{
+ // We can't let the user reset operation affects auto passive output, just let it fail.
+ if (fse->output_thread_running) {
+ printf("fieldstat_easy_reset: reset is not allowed when auto output is enabled.\n");
+ return -1;
+ }
+
+ for (int i = 0; i < fse->max_thread_num; i++) {
+ pthread_spin_lock(&fse->fsu[i].lock);
+ fieldstat_reset(fse->fsu[i].active);
+ // fsu.read_only: Only for output_to_file.
+ pthread_spin_unlock(&fse->fsu[i].lock);
+ }
+
+ // accumulate: Only has data when output_to_file.
+ // delta: Only for output_to_file.
+
+ return 0;
+} \ No newline at end of file