Faster test, add Drone CI
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
DataHoarder 2022-07-13 20:28:00 +02:00
parent d5aae73cd6
commit 736a80d773
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk
4 changed files with 34 additions and 25 deletions

13
.drone.yml Normal file
View file

@ -0,0 +1,13 @@
---
kind: pipeline
type: docker
name: build
steps:
- name: build
image: golang:1.18-bullseye
commands:
- DEBIAN_FRONTEND=noninteractive apt update
- DEBIAN_FRONTEND=noninteractive apt install -y git build-essential cmake make
- git clone --recursive --depth 1 https://git.gammaspectra.live/S.O.N.G/c-gaborator.git && cd c-gaborator && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS_RELEASE="-march=native" -DCMAKE_C_FLAGS_RELEASE="-march=native" -DCMAKE_INSTALL_PREFIX="/usr" && make && make install && cd ../..
- go test -cover -v

View file

@ -4,7 +4,7 @@ Simple Gaborator cgo implementation.
Requires [c-gaborator](https://git.gammaspectra.live/S.O.N.G/c-gaborator) installed.
```shell
git clone --recursive --depth 1 https://git.gammaspectra.live/S.O.N.G/c-gaborator
git clone --recursive --depth 1 https://git.gammaspectra.live/S.O.N.G/c-gaborator.git
cd c-gaborator && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS_RELEASE="-march=native" -DCMAKE_C_FLAGS_RELEASE="-march=native" \

View file

@ -1,13 +0,0 @@
#!/bin/bash
set -ex
pushd "${0%/*}"
pushd c-gaborator
if [[ -d "build" ]]; then
rm -r build
fi
mkdir build
pushd build
cmake ..
make -j$(nproc)

View file

@ -1,15 +1,15 @@
package goborator
import (
"encoding/binary"
"fmt"
"os"
"testing"
"time"
"unsafe"
)
func TestGoborator(t *testing.T) {
ob := NewGaborator(8192, 16000, 85, 110, 7040, 440, 128)
ob := NewGaborator(1<<17, 16000, 85, 110, 7040, 440, 128)
defer ob.ProcessingFinished()
file, err := os.Open("sample/test.raw")
@ -18,29 +18,38 @@ func TestGoborator(t *testing.T) {
return
}
channel := make(chan float32)
channel := make(chan []float32)
go func() {
defer close(channel)
defer file.Close()
var f float32
buf := make([]byte, ob.GetBlockSize()*4)
for {
err = binary.Read(file, binary.LittleEndian, &f)
n, err := file.Read(buf)
if n > 4 {
values := make([]float32, n/4)
copy(values, unsafe.Slice((*float32)(unsafe.Pointer(&buf[0])), n/4))
channel <- values
}
if err != nil {
return
}
channel <- f
}
}()
var i = 0
start := time.Now()
for c := range ob.GaborTransform(channel) {
fmt.Printf("%d: %+F\n", i, c)
i++
var data [][]float32
for c := range ob.GaborBlockTransform(channel) {
data = append(data, c)
}
fmt.Printf("%d, %dms", i, time.Now().Sub(start).Milliseconds())
end := time.Now().Sub(start).Milliseconds()
/*for i, c := range data {
fmt.Printf("%d: %+F\n", i, c)
}*/
fmt.Printf("total: %d, %dms\n", len(data), end)
}