如何测量? [英] How to measure?

查看:41
本文介绍了如何测量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在做性能调优的时候,我会先在high-level工作,尝试回答这是cpu-bound还是IO-bound?

when I did performance-tuning, I will first to work in the high-level and try to answer is this cpu-bound or IO-bound?

当我确定这是cpu-bound时,我会尝试通过添加一些定时器代码来找到热点.这很好,但我没能弄清楚这些问题:

when I make sure this is the cpu-bound, then I will try to find hotspot by adding some timer code.This is good, but I failed to figure out these issues:

  1. 缓存未命中
  2. 线程上下文效果.

有没有人知道如何衡量这些项目?

Is there any one knows how to measure these items?

推荐答案

您是否对性能调优有不同的看法?
它不考虑 I/O 与 CPU 绑定、热点和计时器.

Are you open to a different way of thinking about performance tuning?
It does not look at I/O vs CPU bound, hotspots, and timers.

首先,只考虑一个线程.线程的执行很像一棵树.有一个主要功能(主干).有调用子程序(分支)时的点.有终端指令(叶子)和阻塞调用,如 I/O(水果).程序花费的总时间是所有叶子和所有果实的总和.

First, think about just one thread. The execution of a thread is much like a tree. There is a main function (the trunk). There are points when subroutines are called (branches). There are terminal instructions (leaves) and blocking calls like I/O (fruit). The total time the program takes is the sum of all the leaves and all the fruit.

您想要做的是修剪树,使其尽可能轻,而不是杀死它.

What you want to do is prune the tree, making it as light as possible, without killing it.

许多人所做的是称重(时间)整个事物,然后称重其中的一部分,依此类推,并希望找到可能可以修剪的热点(多叶的树枝).

What many people do is weigh (time) the whole thing, and then weigh parts of it, and so on, and hope to find hotspots (leafy branches) that maybe they could trim.

另一种方法是 1) 随机选择一些叶子或果实.2)从每片叶子或果实,沿着它所在的树枝画一条线,一直回到树干.3)注意上面画有> 1条线的树枝.4) 问我需要这个分支吗?".如果您可以修剪它,请这样做.您将消除树枝的整个重量,并且您在没有称重的情况下完成了这项工作.然后重新开始.

Another way is 1) select some leaves or fruit at random. 2) from each leaf or fruit, paint a line from it along the branch it is on, all the way back to the trunk. 3) Take note of branches that have >1 lines painted on them. 4) Ask "Do I need this branch?". If you can prune it, do so. You will eliminate the entire weight of the branch, and you did it without weighing it. Then start over.

这就是 random 背后的想法- 暂停.它不会发现某些类型的问题,但它会很快找到大多数问题,包括计时线程可以找到的任何问题.

That's the idea behind random-pausing. There are certain kinds of problems it will not find, but most of them it will find, quickly, including any that timing threads can find.

这篇关于如何测量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆