https://github.com/hra42/go-search
Created with CodeSandbox
https://github.com/hra42/go-search
Last synced: 7 months ago
JSON representation
Created with CodeSandbox
- Host: GitHub
- URL: https://github.com/hra42/go-search
- Owner: hra42
- License: unlicense
- Archived: true
- Created: 2023-07-30T11:34:11.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-11T08:50:30.000Z (almost 3 years ago)
- Last Synced: 2025-10-08T00:58:30.091Z (10 months ago)
- Language: Go
- Homepage: https://codesandbox.io/p/github/HRA42/Go-Search
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go Search
## Overview
This Repo shows different search algorithms implemented in Golang.
Every search algorithm is packed into its own folder and loaded into main. I also created a benchmark file.
The main package does implement call for every package that in this module:
1. create an Array of 100000 random integers between 0 and 9223372036854775807 (`math.MaxInt`)
2. run linear search and measure the time it takes to search through the array
3. sort the array and run binary search and measure the time it takes to search through array
4. sort the array and run binary search with concurrency and measure the time it takes to sort the array
5. sort the array and run interpolation search and measure the time it takes to search through array
6. sort the array with concurrency and run interpolation search and measure the time it takes to search through array
---
## Benchmark and Unit Tests
### Benchmark
The benchmark file `tests/main_test.go` does the same, but run with the input cases:
1. 10
2. 100
3. 1000
4. 10000
5. 100000
6. 1000000
7. 10000000
8. 100000000
---
### Unit Tests
Under the intense scrutiny of unit tests, each search algorithm unveils its intricate dance.
The way they align, correct and reorder data – it's like a performer on a stage,
demonstrating their meticulously rehearsed act. Each test is a critical audience,
assessing the show and ensuring that the performance is flawless.
Change the routine? The unit tests won't miss any missteps.
Adapting this practice transforms your routine code into a dynamic spectacle,
elegantly flowing in the theater of your software.
In turn, every line of code is now part of a thrilling performance,
each playing a pivotal role in keeping the audience, which is your software system, captivated.
---
## Codesandbox
You can run this Repo in Codesandbox!
[](https://codesandbox.io/p/github/HRA42/go-search)
---
## Commands to run
### run main.go
```bash
go run cmd/go-search/main.go
```
### run unit test
```bash
go test -v tests/main_test.go
```
### run benchmark
```bash
go test -bench=. tests/main_test.go
```