Code size analysis#

pw_bytes: Utilities for manipulating binary data

This page analyzes the code size impact of using components from the pw_bytes module.

Size report: using ByteBuffer vs. manual manipulation#

The following report compares the code size of using pw::ByteBuffer for constructing and parsing a simple byte sequence versus manually performing similar operations with std::memcpy and bitwise logic for endianness.

pw::ByteBuffer can offer improved type safety and convenience, potentially at a small code size cost for very simple operations, but can lead to more maintainable and less error-prone code for complex byte manipulations.

Label

Segment

Delta

Using ByteBuilder vs. not using it

FLASH

+40

pw::bytes::ReadBytes()

-18

main

-2

pw::metric::Group::Group()

NEW

+38

pw::ByteBuilder::ResizeForAppend()

NEW

+36

pw::ByteBuilder::append()

NEW

+36

pw::bytes::PutBytes()

NEW

+14

pw::ByteBuilder::WriteInOrder<>()

+144

RAM

-8

[section .data]

+1

__Thumbv6MABSLongThunk_best_effort_wfe_or_timeout

DEL

-8

pw::bytes::b_array

NEW

+23

pw::bytes::bb

+8