chromium之histogram.h
histogram不知道是干啥的
// Histogram is an object that aggregates statistics, and can summarize them in // various forms, including ASCII graphical, HTML, and numerically (as a // vector of numbers corresponding to each of the aggregating buckets).
google翻译
//直方图是汇总统计信息的对象,可以将它们汇总 //各种形式,包括ASCII图形,HTML和数字(如 //每个聚合桶对应的数字向量)。
直方图——不就是统计用的,PPT还有饼图什么的
不管了,看看怎么实现的,就知道是干嘛用的了。
瞄一下,有没有引用不认识的头文件
histogram.cc
#include "base/histogram.h"#include <math.h> #include <string>#include "base/logging.h" #include "base/pickle.h" #include "base/string_util.h"
有一个!
#include "base/pickle.h"
参见分析chromium之pickle,我们知道该类提供基本的二进制打包、解包的功能。这样代码就能继续看下去了
这个pickle在头文件里有用到
bool Serialize(Pickle* pickle) const;bool Deserialize(void** iter, const Pickle& pickle);
序列化一般是进程间通讯传递数据用的
序列化在什么时候用:
当你想把的内存中的对象状态保存到一个文件中或者数据库中时候;
当你想用套接字在网络上传送对象的时候;
当你想通过RMI传输对象的时候;
一个类,有没有掌握——给你头文件,你会不会使用里面的函数——会了,这个类你就懂了。
class Pickle;class Histogram {public: //----------------------------------------------------------------------------// Statistic values, developed over the life of the histogram.class SampleSet {public:explicit SampleSet();// Adjust size of counts_ for use with given histogram.void Resize(const Histogram& histogram);void CheckSize(const Histogram& histogram) const;// Accessor for histogram to make routine additions.void Accumulate(Sample value, Count count, size_t index);// Accessor methods.Count counts(size_t i) const { return counts_[i]; }Count TotalCount() const;int64 sum() const { return sum_; }int64 square_sum() const { return square_sum_; }// Arithmetic manipulation of corresponding elements of the set.void Add(const SampleSet& other);void Subtract(const SampleSet& other);bool Serialize(Pickle* pickle) const;bool Deserialize(void** iter, const Pickle& pickle);protected:// Actual histogram data is stored in buckets, showing the count of values// that fit into each bucket. Counts counts_;// Save simple stats locally. Note that this MIGHT get done in base class// without shared memory at some point.int64 sum_; // sum of samples.int64 square_sum_; // sum of squares of samples. };//---------------------------------------------------------------------------- Histogram(const char* name, Sample minimum,Sample maximum, size_t bucket_count);Histogram(const char* name, base::TimeDelta minimum,base::TimeDelta maximum, size_t bucket_count);virtual ~Histogram();void Add(int value);// Accept a TimeDelta to increment.void AddTime(base::TimeDelta time) {Add(static_cast<int>(time.InMilliseconds()));}void AddSampleSet(const SampleSet& sample);// The following methods provide graphical histogram displays.void WriteHTMLGraph(std::string* output) const;void WriteAscii(bool graph_it, const std::string& newline,std::string* output) const;// Support generic flagging of Histograms.// 0x1 Currently used to mark this histogram to be recorded by UMA..// 0x8000 means print ranges in hex.void SetFlags(int flags) { flags_ |= flags; }void ClearFlags(int flags) { flags_ &= ~flags; }int flags() const { return flags_; }virtual BucketLayout histogram_type() const { return EXPONENTIAL; }// Convenience methods for serializing/deserializing the histograms.// Histograms from Renderer process are serialized and sent to the browser.// Browser process reconstructs the histogram from the pickled version// accumulates the browser-side shadow copy of histograms (that mirror// histograms created in the renderer).// Serialize the given snapshot of a Histogram into a String. Uses// Pickle class to flatten the object.static std::string SerializeHistogramInfo(const Histogram& histogram,const SampleSet& snapshot);// The following method accepts a list of pickled histograms and// builds a histogram and updates shadow copy of histogram data in the// browser process.static bool DeserializeHistogramInfo(const std::string& histogram_info);//----------------------------------------------------------------------------// Accessors for serialization and testing.//----------------------------------------------------------------------------const std::string histogram_name() const { return histogram_name_; }Sample declared_min() const { return declared_min_; }Sample declared_max() const { return declared_max_; }virtual Sample ranges(size_t i) const { return ranges_[i];}virtual size_t bucket_count() const { return bucket_count_; }// Snapshot the current complete set of sample data.// Override with atomic/locked snapshot if needed.virtual void SnapshotSample(SampleSet* sample) const;// ... }
看一下测试用例
// Check for basic syntax and use. TEST(HistogramTest, StartupShutdownTest) {// Try basic constructionHistogram histogram("TestHistogram", 1, 1000, 10);Histogram histogram1("Test1Histogram", 1, 1000, 10);LinearHistogram linear_histogram("TestLinearHistogram", 1, 1000, 10);LinearHistogram linear_histogram1("Test1LinearHistogram", 1, 1000, 10);// Use standard macros (but with fixed samples)HISTOGRAM_TIMES("Test2Histogram", TimeDelta::FromDays(1));HISTOGRAM_COUNTS("Test3Histogram", 30);DHISTOGRAM_TIMES("Test4Histogram", TimeDelta::FromDays(1));DHISTOGRAM_COUNTS("Test5Histogram", 30);ASSET_HISTOGRAM_COUNTS("Test6Histogram", 129);// Try to construct samples. Histogram::SampleSet sample1;Histogram::SampleSet sample2;// Use copy constructor of SampleSetsample1 = sample2;Histogram::SampleSet sample3(sample1);// Finally test a statistics recorder, without really using it. StatisticsRecorder recorder; }
看一下效果,浏览器地址栏输入:chrome://histograms/
转载于:https://www.cnblogs.com/ckelsel/p/9032599.html
chromium之histogram.h相关推荐
- 2019cvpr oral | 实时自适应立体匹配
点击上方"3D视觉工坊",选择"星标" 干货第一时间送达 作者:红薯好吃 https://zhuanlan.zhihu.com/p/83411945 本文仅做学 ...
- Cartographer安装
请注意本文的安装日期2017/12/20,如果距离该时间很遥远,请仅作为参考,毕竟cartographer的代码在不断更新,可能会存在很大的变动. 参考文档: https://google-carto ...
- 【机器学习基础】前置知识(五):30分钟掌握常用Matplotlib用法
Matplotlib 是建立在NumPy基础之上的Python绘图库,是在机器学习中用于数据可视化的工具. 我们在前面的文章讲过NumPy的用法,这里我们就不展开讨论NumPy的相关知识了. Matp ...
- TensorRT(5)-INT8校准原理
本次讲一下 tensorRT 的 INT8 低精度推理模式.主要参考 GTC 2017,Szymon Migacz 的PPT . 1 Low Precision Inference 现有的深度学习框架 ...
- MySQL8.0 · 优化器新特性 · Cost Model, 直方图及优化器开销优化
2019独角兽企业重金招聘Python工程师标准>>> MySQL当前已经发布到MySQL8.0版本,在新的版本中,可以看到MySQL之前被人诟病的优化器部分做了很多的改动,由于笔者 ...
- 使用COSBench工具对ceph s3接口进行压力测试--续
之前写的使用COSBench工具对ceph s3接口进行压力测试是入门,在实际使用是,配置内容各不一样,下面列出 压力脚本是xml格式的,套用UserGuide文档说明,如下 有很多模板的例子,在co ...
- 揭秘Facebook官方底层C++函数Folly
2019独角兽企业重金招聘Python工程师标准>>> Folly与Boost.当然还有std等组件库的关系是互为补充,而不是彼此竞争.实际上,只有当我们需要的东西既没有,也无法满足 ...
- OpenCV中感兴趣区域的选取与检测(一)
1.感兴趣区域的选取 感兴趣区域(Region of Interest, ROI)的选取,一般有两种情形:1)已知ROI在图像中的位置:2)ROI在图像中的位置未知. 1)第一种情形 很简单,根据RO ...
- python坐标轴拉伸_python-Matplotlib垂直拉伸histogram2d
事情被"拉伸"了,因为您正在使用imshow.默认情况下,它假定您要显示图像的纵横比为1(在数据坐标中). 如果要禁用此行为,并让像素拉伸以填满绘图,只需指定Aspect =&qu ...
最新文章
- 加权残差连接ReZero
- 与通用计算机相比 单片机具体有哪些特点,嵌入式系统-复习大纲_彭荣
- laravel + Vue 前后端分离 之 项目配置- 生产环境部署
- 【Python入门】一个有意思还有用的Python包-汉字转换拼音
- java中的日期时间的计算与比较
- Nagios监控之8:利用mutt+msmtp实现邮件报警
- C#-代码片段的使用(1) 039
- php curl 采集文件,curl获取远程文件内容
- ASP注入漏洞基础教程(二)
- 用MATLAB实现神经网络
- SIGGRAPH 2020 | 基于样例的虚拟摄影和相机控制
- java环境变量配置 - win10
- Netty : 臭名昭著的JDK的NIO bug(空轮询bug)
- 链队列出入队列c语言程序,链队列简单操作(c语言)
- SASS-HRM-Day04
- I2C分析及RX8025驱动编写
- 如何使用一键回录游戏视频
- 【React】入门实例
- win10右键卡顿原因_win10右键新建卡顿的问题
- Cisco Packet Tracer汉化
热门文章
- Linux 命令之 kill -- 杀死进程
- JJWT签发与验证token
- python画统计图代码_Python使用统计函数绘制简单图形实例代码
- C语言预处理命令分类和工作原理
- html流式布局插件,Jquery瀑布流网格布局插件
- c++矩阵连乘的动态规划算法并输出_「Javascript算法设计」× 动态规划与回溯算法...
- 微信分享 ajax冲突,微信jssdk分享功能开发及解决ajax跨域的问题
- 交换机选用要点及订货主要技术条件
- 关于工业交换机技术的简单总结
- 什么是语音复用设备?