https://github.com/fumiama/sched
Simple Golang parallel scheduler.
https://github.com/fumiama/sched
coroutines golang golang-library golang-module golang-package multiprocessing multithreading parallel-computing parallel-processing parallel-programming task-manager task-runner task-scheduler
Last synced: 12 months ago
JSON representation
Simple Golang parallel scheduler.
- Host: GitHub
- URL: https://github.com/fumiama/sched
- Owner: fumiama
- License: agpl-3.0
- Created: 2025-02-16T12:46:32.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-16T13:43:29.000Z (about 1 year ago)
- Last Synced: 2025-03-13T09:51:57.120Z (about 1 year ago)
- Topics: coroutines, golang, golang-library, golang-module, golang-package, multiprocessing, multithreading, parallel-computing, parallel-processing, parallel-programming, task-manager, task-runner, task-scheduler
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sched
Simple Golang parallel scheduler.
## Usage
### Add one to each element in arr
```go
arr := make([]uint8, 64*1024*1024) // 64M
_, _ = NewTask(arr, func(_ int, x []byte) ([]byte, error) {
for i := range x {
arr[i]++
}
return arr, nil
}, false, false).Collect(2*1024*1024, true, true) // 2M batch
```
### Get HTTP contents for earh URL
```go
contents, err := NewTask(urls, func(_ int, urls []string) ([]string, error) {
for i, u := range url {
str, err := ... // get content
if err != nil {
return nil, err
}
urls[i] = str // overlap
}
return urls, nil // return result
}, false, false).Collect(4, false, false) // 4 URLs as a group
```
## Bechmark
A simple self-incrasing process is performed on a 64M uint8 array.
```c
goos: darwin
goarch: arm64
pkg: github.com/fumiama/sched
cpu: Apple M1
BenchmarkSched/single-8 1000000000 0.02992 ns/op 2242952686132.55 MB/s 0 B/op 0 allocs/op
BenchmarkSched/para512K-8 1000000000 0.02483 ns/op 2702751323377.81 MB/s 0 B/op 0 allocs/op
BenchmarkSched/para1M-8 1000000000 0.02492 ns/op 2693026104055.06 MB/s 0 B/op 0 allocs/op
BenchmarkSched/para2M-8 1000000000 0.02133 ns/op 3146490138908.33 MB/s 0 B/op 0 allocs/op
PASS
ok github.com/fumiama/sched 1.119s
```