Chapter 5
Improving the Performance of Your CLI Tools

Ensuring that your command-line tools perform well is an important requirement, especially when designing tools that process a large amount of information, like data analysis tools. But designing tools that perform well isn’t an easy task. Performance is often a subjective concept; it varies from person to person and also according to the context. In this book, we’ll define performance as the speed of execution, or how fast our program can handle its workload.

Go provides tools that help you measure and analyze a program’s performance. It has integrated tools for testing, benchmarking, profiling, and tracing.

To explore those tools, you’ll build a CLI application that executes statistical operations on a CSV file. The CSV format consists of tabular data separated by commas. This format is commonly used to store numeric data for statistical and data analysis.

Here is an example of a CSV file:

 IP Address,Timestamp,Response Time,Bytes
 192.168.0.199,1520698621,236,3475
 192.168.0.88,1520698776,220,3200
 192.168.0.199,1520699033,226,3200
 192.168.0.100,1520699142,218,3475
 192.168.0.199,1520699379,238,3822

You’ll build an initial version of this tool, test it to ensure it works correctly, and measure its performance by executing benchmarks. Then you’ll analyze its performance by executing profiling and tracing, and you’ll use an iterative approach to improve it. You’ll use different strategies to improve the program, including applying Go’s concurrency primitives to build a version of the tool that executes concurrently.

Let’s get started.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.105.193