Ada>> rap>> 返回
项目作者: recolude

项目描述 :
Official format for time series data captured from 3D Engines.
高级语言: Go
项目地址: git://github.com/recolude/rap.git
创建时间: 2021-01-24T19:44:23Z
项目社区:https://github.com/recolude/rap

开源协议:

下载


RAP

Build Status codecov
Go Report Card

RAP is in Beta

Recolude’s official recording file format. Ain’t no kill like overkill.

Install

  1. git clone https://github.com/recolude/rap
  2. cd rap
  3. go install ./cmd/rap-cli

CLI Usage

  1. NAME:
  2. RAP CLI - Utils around recolude file format
  3. USAGE:
  4. rap-cli [global options] command [command options] [arguments...]
  5. VERSION:
  6. 1.0.0
  7. AUTHOR:
  8. Eli Davis <eli@recolude.com>
  9. COMMANDS:
  10. from-csv Builds a recording from CSV
  11. json Transforms a file to json
  12. summarize Summarizes a file
  13. upgrade Upgrades a file from v1 to v2
  14. help, h Shows a list of commands or help for one command
  15. GLOBAL OPTIONS:
  16. --help, -h show help (default: false)
  17. --version, -v print the version (default: false)

Building Recordings Programmatically

With this new library you can create your own recordings programmatically. The below example creates a recording of the sin wave and then writes it to disk.

  1. package main
  2. import (
  3. "math"
  4. "os"
  5. "time"
  6. "github.com/recolude/rap/format"
  7. "github.com/recolude/rap/format/collection/position"
  8. "github.com/recolude/rap/format/encoding"
  9. positionEncoder "github.com/recolude/rap/format/encoding/position"
  10. "github.com/recolude/rap/format/io"
  11. "github.com/recolude/rap/format/metadata"
  12. )
  13. func main() {
  14. iterations := 1000
  15. positions := make([]position.Capture, iterations)
  16. start := time.Now()
  17. for i := 0; i < iterations; i++ {
  18. currentTime := float64(i)
  19. positions[i] = position.NewCapture(currentTime, 0, math.Sin(currentTime), 0)
  20. }
  21. duration := time.Since(start)
  22. rec := format.NewRecording(
  23. "",
  24. "Sin Wave Demo",
  25. []format.CaptureCollection{
  26. position.NewCollection("Sin Wave", positions),
  27. },
  28. nil,
  29. metadata.NewBlock(map[string]metadata.Property{
  30. "iterations": metadata.NewIntProperty(iterations),
  31. "benchmark": metadata.NewStringProperty(duration.String()),
  32. }),
  33. nil,
  34. nil,
  35. )
  36. f, _ := os.Create("sin demo.rap")
  37. recordingWriter := io.NewWriter(
  38. []encoding.Encoder{
  39. positionEncoder.NewEncoder(positionEncoder.Oct24),
  40. },
  41. true,
  42. f,
  43. io.BST16,
  44. )
  45. // Writes a recording in 1,171 bytes
  46. recordingWriter.Write(rec)
  47. }

Testing Locally

You need to generate mocks before you can run parts of the test suite.

  1. go generate ./...

There are also benchmark(s)

  1. go test ./format/io -bench=. -cpuprofile cpu.prof
  2. go tool pprof -svg cpu.prof > cpu.svg