• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

llnl / dftracer-utils / 28693295402

04 Jul 2026 03:17AM UTC coverage: 52.408% (+0.1%) from 52.278%
28693295402

push

github

hariharan-devarajan
feat: silence noisy warnings on aarch64

37318 of 92666 branches covered (40.27%)

Branch coverage included in aggregate %.

33462 of 42389 relevant lines covered (78.94%)

20557.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.62
/src/dftracer/utils/python/utilities/statistics_aggregator.cpp
1
#define PY_SSIZE_T_CLEAN
2
#include <dftracer/utils/core/coro/task.h>
3
#include <dftracer/utils/core/runtime.h>
4
#include <dftracer/utils/python/py_dict_helpers.h>
5
#include <dftracer/utils/python/py_runtime_mixin.h>
6
#include <dftracer/utils/python/py_type_helpers.h>
7
#include <dftracer/utils/python/runtime.h>
8
#include <dftracer/utils/python/utilities/statistics_aggregator.h>
9
#include <dftracer/utils/utilities/composites/dft/internal/utils.h>
10
#include <dftracer/utils/utilities/composites/dft/statistics/statistics_aggregator_utility.h>
11
#include <dftracer/utils/utilities/composites/dft/statistics/trace_statistics.h>
12

13
#include <string>
14

15
using dftracer::utils::Runtime;
16
using dftracer::utils::coro::CoroTask;
17
using namespace dftracer::utils::utilities::composites::dft::statistics;
18

19
DFTRACER_UTILS_RUNTIME_BACKED_SLOTS(StatisticsAggregator,
42✔
20
                                    StatisticsAggregatorObject)
21

22
static PyObject *StatisticsAggregator_compute(StatisticsAggregatorObject *self,
14✔
23
                                              PyObject *args, PyObject *kwds) {
24
    static const char *kwlist[] = {"file_path", "index_dir", NULL};
25
    const char *file_path;
26
    const char *index_dir = "";
14✔
27
    if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|s", (char **)kwlist,
14!
28
                                     &file_path, &index_dir))
29
        return NULL;
×
30

31
    std::string file_path_str(file_path);
14!
32
    std::string index_dir_str(index_dir);
14!
33
    TraceStatistics stats;
14!
34

35
    if (!run_blocking([&] {
21!
36
            Runtime *rt = resolve_runtime(self);
14!
37

38
            StatisticsAggregatorInput input;
14✔
39
            input.file_path = file_path_str;
14!
40
            input.index_dir = index_dir_str;
14!
41
            input.index_path = dftracer::utils::utilities::composites::dft::
7!
42
                internal::determine_index_path(file_path_str, index_dir_str);
14!
43

44
            auto *stats_p = &stats;
14✔
45
            auto input_copy = input;
14!
46
            auto task = [stats_p, input_copy]() -> CoroTask<void> {
63!
47
                StatisticsAggregatorUtility util;
21!
48
                *stats_p = co_await util.process(input_copy);
28!
49
            };
42!
50
            rt->submit(task(), "stats-aggregator").get();
14!
51
        })) {
14✔
52
        return NULL;
×
53
    }
54

55
    PyObject *d = PyDict_New();
14!
56
    if (!d) return NULL;
14✔
57

58
    int rc = 0;
14✔
59
    rc |= dict_set_str(d, "file_path", stats.file_path.c_str());
14!
60
    rc |= dict_set_u64(d, "total_events", stats.total_events());
14!
61
    rc |= dict_set_u64(d, "num_chunks", stats.num_chunks);
14!
62
    rc |= dict_set_bool(d, "success", stats.success);
14!
63
    rc |= dict_set_str(d, "error_message", stats.error_message.c_str());
14!
64
    rc |= dict_set_f64(d, "time_span_seconds", stats.time_span_seconds());
14!
65
    rc |= dict_set_f64(d, "duration_mean_us", stats.duration_mean_us());
14!
66
    rc |= dict_set_f64(d, "duration_stddev_us", stats.duration_stddev_us());
14!
67
    rc |= dict_set_size(d, "num_categories", stats.num_categories());
14!
68
    rc |= dict_set_size(d, "num_unique_names", stats.num_unique_names());
14!
69
    rc |= dict_set_size(d, "num_pid_tids", stats.num_pid_tids());
14!
70
    rc |= dict_set_u64(d, "min_timestamp_us", stats.merged.min_timestamp_us);
14!
71
    rc |= dict_set_u64(d, "max_timestamp_us", stats.merged.max_timestamp_us);
14!
72

73
    if (rc != 0) {
14!
74
        Py_DECREF(d);
×
75
        return NULL;
×
76
    }
77

78
    return d;
14✔
79
}
14✔
80

81
static PyObject *StatisticsAggregator_call(PyObject *self, PyObject *args,
2✔
82
                                           PyObject *kwds) {
83
    return StatisticsAggregator_compute((StatisticsAggregatorObject *)self,
3✔
84
                                        args, kwds);
2✔
85
}
86

87
static PyMethodDef StatisticsAggregator_methods[] = {
88
    {"process", (PyCFunction)StatisticsAggregator_compute,
89
     METH_VARARGS | METH_KEYWORDS,
90
     "process(file_path, index_dir='')\n"
91
     "--\n"
92
     "\n"
93
     "Compute aggregated statistics from a trace file.\n"
94
     "\n"
95
     "Args:\n"
96
     "    file_path (str): Path to the trace file.\n"
97
     "    index_dir (str): Directory for .dftindex stores (default '').\n"
98
     "\n"
99
     "Returns:\n"
100
     "    dict: Aggregated statistics.\n"},
101
    {NULL}};
102

103
PyTypeObject StatisticsAggregatorType = {
104
    PyVarObject_HEAD_INIT(
105
        NULL, 0) "dftracer_utils_ext.StatisticsAggregatorUtility", /* tp_name */
106
    sizeof(StatisticsAggregatorObject),       /* tp_basicsize */
107
    0,                                        /* tp_itemsize */
108
    (destructor)StatisticsAggregator_dealloc, /* tp_dealloc */
109
    0,                                        /* tp_vectorcall_offset */
110
    0,                                        /* tp_getattr */
111
    0,                                        /* tp_setattr */
112
    0,                                        /* tp_as_async */
113
    0,                                        /* tp_repr */
114
    0,                                        /* tp_as_number */
115
    0,                                        /* tp_as_sequence */
116
    0,                                        /* tp_as_mapping */
117
    0,                                        /* tp_hash */
118
    StatisticsAggregator_call,                /* tp_call */
119
    0,                                        /* tp_str */
120
    0,                                        /* tp_getattro */
121
    0,                                        /* tp_setattro */
122
    0,                                        /* tp_as_buffer */
123
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
124
    "StatisticsAggregatorUtility(runtime: Runtime | None = None)\n"
125
    "--\n\n"
126
    "Aggregate statistics from an indexed trace file.\n\n"
127
    "Args:\n"
128
    "    runtime (Runtime or None): Runtime for thread pool control.\n",
129
    0,                                   /* tp_traverse */
130
    0,                                   /* tp_clear */
131
    0,                                   /* tp_richcompare */
132
    0,                                   /* tp_weaklistoffset */
133
    0,                                   /* tp_iter */
134
    0,                                   /* tp_iternext */
135
    StatisticsAggregator_methods,        /* tp_methods */
136
    0,                                   /* tp_members */
137
    0,                                   /* tp_getset */
138
    0,                                   /* tp_base */
139
    0,                                   /* tp_dict */
140
    0,                                   /* tp_descr_get */
141
    0,                                   /* tp_descr_set */
142
    0,                                   /* tp_dictoffset */
143
    (initproc)StatisticsAggregator_init, /* tp_init */
144
    0,                                   /* tp_alloc */
145
    StatisticsAggregator_new,            /* tp_new */
146
};
147

148
int init_statistics_aggregator(PyObject *m) {
2✔
149
    if (register_type(m, &StatisticsAggregatorType,
2✔
150
                      "StatisticsAggregatorUtility") < 0)
2✔
151
        return -1;
×
152

153
    return 0;
2✔
154
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc