BW_MEM(8)
π BW_MEM β like, the whole vibe π
okay bestie, gather round, because we're about to talk about bw_mem from the LMBENCH crew (section 8, system admin girlies only π
). it's literally a memory bandwidth timer. that's it, that's the girl. β¨
β¨ NAME β¨
bw_mem β it times your memory bandwidth, no cap π§ π₯
π¦ SYNOPSIS π¦
bw_mem_cp [ -P <parallelism> ] [ -W <warmups> ] [ -N <repetitions> ]
size rd|wr|rdwr|cp|fwr|frd|bzero|bcopy [align]
yes the synopsis says bw_mem_cp and yes we are keeping it exactly like that. i don't make the rules, i just obey them π«Ά
πΈ DESCRIPTION πΈ
so here's the tea π: bw_mem allocates twice the amount of memory you asked for, zeroes it all out, and then times how long it takes to copy the first half into the second half. results come back in megabytes moved per second. it's giving speed test but make it memory.
the size you pass can end with k or m, which means kilobytes (* 1024) or megabytes (* 1024 * 1024). k? m? iconic abbreviations, we love to see it. π
π OUTPUT π
the output format is "%0.2f %.2f\n", and it spits out megabytes then megabytes_per_second, like this:
8.00 25.33
there are nine different memory benchmarks hiding inside bw_mem, and each one measures a slightly different way of reading, writing, or copying data. nine. a whole squad. let's meet them π«Ά
rdβ measures the time to read data into the processor. it computes the sum of an array of integer values. and it accesses every fourth word. (every fourth word. she's picky and i respect it.)wrβ measures the time to write data to memory. it assigns a constant value to each memory of an array of integer values. it accesses every fourth word.rdwrβ measures the time to read data into memory and then write data to the same memory location. for each element in an array it adds the current value to a running sum before assigning a new (constant) value to the element. it accesses every fourth word. read, write, read, write β main character energy, honestly.cpβ measures the time to copy data from one location to another. it does an array copy:dest[i] = source[i]. it accesses every fourth word.frdβ measures the time to read data into the processor. it computes the sum of an array of integer values.fwrβ measures the time to write data to memory. it assigns a constant value to each memory of an array of integer values.fcpβ measures the time to copy data from one location to another. it does an array copy:dest[i] = source[i].bzeroβ measures how fast the system canbzeromemory.bcopyβ measures how fast the system canbcopydata.
ngl bestie, if you clocked that the synopsis listscpbut the benchmark list also hasfcpβ yes. both exist. both are real. we are not merging them, that would be a crime π
π MEMORY UTILIZATION π
this is the part where we keep it real. this benchmark can move up to three times the requested memory. bcopy will use 2-3 times as much memory bandwidth: there's one read from the source and a write to the destination. the write usually results in a cache line read and then a write back of the cache line at some later point. π«
memory utilization might be reduced by 1/3 if the processor architecture implemented load cache line and store cache line instructions (as well as getcachelinesize). so, like, a third off. noted. π§
π SEE ALSO π
π AUTHOR π
Carl Staelin and Larry McVoy
comments, suggestions, and bug reports are always welcome. (they literally said "always welcome" β so go off, bestie, send that feedback π«Ά)
and that's the whole page, fr fr π this was BW_MEM(8) from LMBENCH, brought to you by the copyright girlies: Β©1994-2000 Larry McVoy and Carl... and stamped with a very mysterious $Date$. slay, periodt. β¨π
π¦ where this page comes from
- debian bookworm: lmbench 3.0-a9+debian.1-6
- debian trixie: lmbench 3.0-a9+debian.1-9
- ubuntu jammy: lmbench 3.0-a9+debian.1-6
- ubuntu noble: lmbench 3.0-a9+debian.1-6build3
- ubuntu questing: lmbench 3.0-a9+debian.1-9
- ubuntu resolute: lmbench 3.0-a9+debian.1-10
- ubuntu stonking: lmbench 3.0-a9+debian.1-10
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms