liveBook · Manning

Energy consumption

As explained in The Art of Code

Energy consumption is the amount of electrical or other energy required to operate software and its supporting computing systems.

A fast program is not necessarily an energy-efficient one. The practical goal is to deliver acceptable responsiveness with as little hardware and electricity as possible. Clean code, performance, and sustainability are related concerns, but improving one does not automatically improve the others. section 8.3

Usage changes the lifecycle balance

Roughly 75% of a smartphone’s lifetime carbon emissions arise before it is turned on. For servers, the pre-use share is lower—about 30%–40%—because electricity consumption dominates over years of operation. Reducing electricity use matters, but so does keeping functional devices in service rather than forcing replacement through unsupported or increasingly demanding software. section 8.2.2

To investigate waste, distinguish static analysis from runtime observation. Static analysis can flag resource-wasting patterns without running code; dynamic analysis can observe behavior, including energy consumption. Microbenchmarks and CPU or memory profilers provide another route to finding inefficient work, though their resource measurements should not be mistaken for direct energy measurements. section 8.5.2

A storage decision

For a PostgreSQL customer table, inspect field types, sizes, and redundant information, then consider what data still needs to be retained. Keeping less unnecessary data and accumulated waste can reduce hardware needs and energy consumption. Delete data when it is no longer needed, unless legal requirements call for retention. section 8.4.3

How The Art of Code covers it

How deep it goes
Distinguishes runtime energy observation from static analysis and resource profiling, without providing a direct energy-measurement procedure.
Examples
Contrasts smartphone and server lifecycle emissions and uses a PostgreSQL customer-table exercise to examine storage waste.
What you can do after
Diagnose/debug with runtime observation and resource profiling, then evaluate reductions in waste against acceptable responsiveness.
How it connects
Connects energy consumption to performance, clean code, embodied carbon, hardware lifespan, and lean storage.

Also explained in

Compare how 5 books explain energy consumption →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Art of Code. The section links point to the parts of the book it draws on.