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.

Energy consumption is the energy required while software and its supporting systems operate. In sustainable software work, it is an impact dimension alongside code clarity and responsiveness: the aim is an acceptable result with the smallest practical hardware footprint, rather than treating speed or code appearance as a direct proxy for sustainability. section 8.3

Operational electricity is only part of a device’s lifecycle impact. Manufacturing, transport, and end-of-life processing create embodied carbon emissions; for servers, ongoing electricity consumption tends to account for a larger share over their five-to-seven-year lifespan. Keeping devices in service through repair, reuse, or repurposing can spread embodied impact over more time. section 8.2.2

Treat lower energy use as a resource-efficiency problem with practical tradeoffs:

  • Set a responsiveness level users actually need, then meet it with the minimum hardware resources instead of pursuing speed without limits. section 8.3
  • Measure small alternatives in isolation with a microbenchmark, then use profilers to inspect CPU behavior and memory allocation in deeper runtime analysis. section 8.5.2
  • Avoid retaining operationally useless data. Leaner storage and less accumulated waste reduce hardware needs and associated energy consumption. section 8.4.3
  • Distinguish static analysis, which examines code without running it, from dynamic analysis, which observes runtime behavior including energy consumption and environmental impact. section 8.5.2

Storage as an energy decision

A customer table can consume more resources than its business purpose requires when it uses oversized fields, unsuitable data types, or redundant information. Reviewing field sizes, data types, and normalization makes storage needs visible; deleting data once it is no longer needed, except where law requires retention, limits continuing operational waste. section 8.4.3

Figure 8.1 How sustainable coding fits with clean code and performance
figure

Use the diagram to place sustainable coding between clean code and performance: efficiency joins acceptable responsiveness to minimal resource use, while sustainability adds infrastructure, electricity, environmental, and cost impact. section 8.3

A useful heuristic is to preserve readable, maintainable code while checking whether its runtime, memory, stored data, and required infrastructure are proportionate to the result users need. Measure before assuming that a clean implementation, a fast implementation, or more powerful hardware is the sustainable choice. section 8.5.2 section 8.3

How The Art of Code covers it

How deep it goes
Explains lifecycle context, efficiency tradeoffs, measurement approaches, and lean storage without detailing energy-estimation implementations.
Examples
Uses server lifespans, obsolete devices, a PostgreSQL customer-table exercise, microbenchmarks, and CPU-memory profilers.
What you can do after
Apply it via microbenchmarks and profilers to compare runtime resource behavior and reduce avoidable storage waste.
How it connects
Connects sustainable coding with clean code, performance, efficiency, static analysis, dynamic analysis, profiling, 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.