@@ -646,11 +646,11 @@ class AvgKernel : public AggregateKernel
646
646
647
647
int prop = CALI_ATTR_SKIP_EVENTS | CALI_ATTR_ASVALUE;
648
648
649
- m_stat_attrs.avg = db.create_attribute (" avg#" + m_target_attr_name, CALI_TYPE_DOUBLE , prop);
649
+ m_stat_attrs.avg = db.create_attribute (" avg#" + m_target_attr_name, m_target_attr. type () , prop);
650
650
m_stat_attrs.count =
651
651
db.create_attribute (" avg.count#" + m_target_attr_name, CALI_TYPE_UINT, prop | CALI_ATTR_HIDDEN);
652
652
m_stat_attrs.sum =
653
- db.create_attribute (" avg.sum#" + m_target_attr_name, CALI_TYPE_DOUBLE , prop | CALI_ATTR_HIDDEN);
653
+ db.create_attribute (" avg.sum#" + m_target_attr_name, m_target_attr. type () , prop | CALI_ATTR_HIDDEN);
654
654
655
655
a = m_stat_attrs;
656
656
return true ;
@@ -663,7 +663,7 @@ class AvgKernel : public AggregateKernel
663
663
static AggregateKernelConfig* create (const std::vector<std::string>& cfg) { return new Config (cfg.front ()); }
664
664
};
665
665
666
- AvgKernel (Config* config) : m_count(0 ), m_sum( 0.0 ), m_config(config) {}
666
+ AvgKernel (Config* config) : m_count(0 ), m_config(config) {}
667
667
668
668
const AggregateKernelConfig* config () { return m_config; }
669
669
@@ -679,10 +679,10 @@ class AvgKernel : public AggregateKernel
679
679
680
680
for (const Entry& e : list) {
681
681
if (e.attribute () == target_attr.id ()) {
682
- m_sum += e.value (). to_double () ;
682
+ m_sum += e.value ();
683
683
++m_count;
684
684
} else if (e.attribute () == stat_attr.sum .id ()) {
685
- m_sum += e.value (). to_double () ;
685
+ m_sum += e.value ();
686
686
} else if (e.attribute () == stat_attr.count .id ()) {
687
687
m_count += e.value ().to_uint ();
688
688
}
@@ -697,16 +697,16 @@ class AvgKernel : public AggregateKernel
697
697
if (!m_config->get_statistics_attributes (db, stat_attr))
698
698
return ;
699
699
700
- list.push_back (Entry (stat_attr.avg , Variant ( m_sum / m_count)));
701
- list.push_back (Entry (stat_attr.sum , Variant ( m_sum) ));
700
+ list.push_back (Entry (stat_attr.avg , m_sum. div ( m_count)));
701
+ list.push_back (Entry (stat_attr.sum , m_sum));
702
702
list.push_back (Entry (stat_attr.count , Variant (cali_make_variant_from_uint (m_count))));
703
703
}
704
704
}
705
705
706
706
private:
707
707
708
708
unsigned m_count;
709
- double m_sum;
709
+ Variant m_sum;
710
710
711
711
std::mutex m_lock;
712
712
0 commit comments