liveBook · Manning

Skew

As explained in Modern C, Third Edition

Skew measures the asymmetry or lopsidedness of a distribution around its mean.

Suppose 20 runs produce timings from 0.1 to 1.3 seconds, with a mean of 0.6 seconds. The range and standard deviation describe variation; skew describes whether the timings are lopsided around the mean. Do not infer skew from the endpoints alone: inspect how often values occur on each side. section 16.4

Figure 16.1 Frequency histogram for our sample, showing the frequency with which each of the measured values was obtained
figure

The frequency histogram shows how often each of the 20 timings occurred, making the distribution easier to inspect than a list of values. section 16.4

TAKEAWAY: Repeated timings need more than an average when measurements vary substantially. Skew can help characterize their asymmetry, but collecting statistics also changes the measurement. In the illustrated comparison, adding skew collection increased measured time per iteration by 9% over the preceding setup. section 16.4

Table 16.1 Comparison of measurements
Loop Sec per iteration Difference Gain/loss Conclusive
0 volatile loop 1.97⋅10-09
1 volatile store 3.66⋅10-10 -1.60⋅10-09 -81% Yes
2 Opaque addition 3.45⋅10-10 -2.10⋅10-11 -6% No
3 Plus timespec_get 1.77⋅10-08 1.74⋅10-08 +5043% Yes
4 Plus mean 2.62⋅10-08 8.5⋅10-09 +48% Yes
5 Plus variance 2.90⋅10-08 2.8⋅10-09 +11% Yes
6 Plus skew 3.17⋅10-08 2.7⋅10-09 +9% Yes

The comparison table separates the cost of collecting skew from earlier additions of the mean and variance. section 16.4

How Modern C, Third Edition covers it

How deep it goes
Defines skew as asymmetry and places it among timing statistics without giving a formula or calculating it for the sample.
Examples
Uses 20 fictive timings, a frequency histogram, and a comparison table showing 9% overhead from adding skew collection.
What you can do after
Evaluate/understand it as one descriptor of lopsided timings while accounting for the cost of collecting statistics.
How it connects
Connects skew to performance measurement, the mean, standard deviation, histograms, and instrumentation bias.

Also explained in

Compare how 5 books explain skew →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.