Lead Image © Lucy Baldwin, 123RF.com
Go testing frameworks
Going Faster
Traditionally the best language to implement command-line interface (CLI) shell utilities in Linux was Perl [1] – primarily because of its large collection of pre-existing modules, a resource unparalleled at the time called CPAN [2]. Things have since changed, with Perl's popularity steadily declining in the eyes of developers and other languages rising to produce comparably large module libraries, as in Python [3] or Node [4].
Recent books have been published about writing shell commands in Rust [5], Python [6], Node.js [7], and even Go [8], and it is into this last language's interesting performance testing facilities I shall delve deeper. Go famously includes a testing framework, but perhaps less well known is its equally impressive built-in performance testing facility.
To start, the directories should be set up as presented in Figure 1, with the project row.go detailed in Listing 1.
Listing 1
row.go
01 package main
02
03 func main() {
04
05 const size = 10
06
07 var array = [size][size]int {{0},{0},}
08
09 for i := 0; i < size; i++ {
10 for j := 0; j < size; j++ {
11 array[i][j]++
12 }
13 }
14
15 }
Buy this article as PDF
(incl. VAT)
