From 736a80d773e7c3dd83229148104850c41e2a1562 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+WeebDataHoarder@users.noreply.github.com> Date: Wed, 13 Jul 2022 20:28:00 +0200 Subject: [PATCH] Faster test, add Drone CI --- .drone.yml | 13 +++++++++++++ README.md | 2 +- build-deps.sh | 13 ------------- goborator_test.go | 31 ++++++++++++++++++++----------- 4 files changed, 34 insertions(+), 25 deletions(-) create mode 100644 .drone.yml delete mode 100755 build-deps.sh diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..bae7620 --- /dev/null +++ b/.drone.yml @@ -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 \ No newline at end of file diff --git a/README.md b/README.md index 5282010..8cd9a70 100644 --- a/README.md +++ b/README.md @@ -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" \ diff --git a/build-deps.sh b/build-deps.sh deleted file mode 100755 index 77b3e7c..0000000 --- a/build-deps.sh +++ /dev/null @@ -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) \ No newline at end of file diff --git a/goborator_test.go b/goborator_test.go index 043abd2..94f0dcc 100644 --- a/goborator_test.go +++ b/goborator_test.go @@ -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) }