Skip to content

Commit

Permalink
Add sample benchmark tests for SpellNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
egasimov committed Mar 1, 2023
1 parent 08b544b commit 1c6bfe4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
-->

![aznum2words logo](assets/img/logo-v2.png)

- - -
![CI](https://github.com/egasimov/aznum2words/actions/workflows/ci.yml/badge.svg?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/egasimov/aznum2words)](https://goreportcard.com/report/github.com/egasimov/aznum2words)
![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/egasimov/aznum2words?sort=semver)
Expand All @@ -21,7 +21,6 @@
[//]: # ([![Github Last Commit](https://img.shields.io/github/last-commit/egasimov/aznum2words?color=61dfc6&label=last%20commit)]())
[//]: # (![GitHub all releases](https://img.shields.io/github/downloads/egasimov/aznum2words/total))

## Məlumat | Description

**AzNum2Words** - Azərbaycan dilində ədədlərin sözlə yazılışı(və ya təsviri) üçün nəzərdə tutulan Go
dilində yazılmış, açıq qaynaqlı kitabxanadır.
Expand Down Expand Up @@ -109,7 +108,7 @@ beş milyard altı yüz on bir milyon bir yüz on üç min iki yüz on

```shell
// installs the binaries into $GOPATH/bin
go install github.com/egasimov/aznum2words@latest
go install github.com/egasimov/aznum2words/cmd/cliapp/aznum2words-cli@latest
```

## CLI kimi istifadə qaydası | Guideline for using as CLI app
Expand All @@ -128,9 +127,16 @@ mənfi on iki tam onda üç
## Test caseləri yoxlanması | Check test cases

```shell
go test ./..
go test ./...
```

## Benchmark yoxlanılması

```shell
go test -bench=. -run=^# -benchmem
```


- - -

## Versiyalar | Releases
Expand Down
31 changes: 31 additions & 0 deletions aznum2words_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package aznum2words

import (
"fmt"
"github.com/egasimov/aznum2words/fixtures"
"reflect"
"testing"
Expand Down Expand Up @@ -111,3 +112,33 @@ func Test_SpellNumber_WhereNegativeFloatingPointNumber(t *testing.T) {
}
}
}

func BenchmarkSpellNumber(b *testing.B) {
dataTable := []struct {
input string
}{
{
input: "12345",
},
{
input: "1234567890",
},
{
input: "1234567890123456789012345"},
{
input: "12345678901234567890123456789012345678901234567890",
},
{
input: "493882371553121860890561055192142938414552660618128252927700430053",
},
}

for _, v := range dataTable {
testName := fmt.Sprintf("digitCnt-%d_gomaxproc", len(v.input))
b.Run(testName, func(b *testing.B) {
for i := 0; i < b.N; i++ {
SpellNumber(v.input)
}
})
}
}

0 comments on commit 1c6bfe4

Please sign in to comment.