drmg17928 2014-09-05 18:15
浏览 56

在heroku上运行golang测试

I more or less followed these instructions to deploy my app to heroku. Everything works well.

http://mmcgrana.github.io/2012/09/getting-started-with-go-on-heroku.html

I've got some benchmarking tests that I'd like to run on heroku to test whether or not there's a difference in performance between my local machine and the heroku box. Unfortunately I can't figure out how to run them (heroku can't find the go executable). Is it possible to do this?

Thanks!

  • 写回答

1条回答 默认 最新

  • dqf60304 2014-09-06 01:25
    关注

    I haven't used Heroku. It's possible that Heroku has a problem running a benchmark using the go test command; there may be a problem with the temporary directory.

    Command go

    Test packages

    'Go test' recompiles each package along with any files with names matching the file pattern "*test.go". Files whose names begin with "" (including "_test.go") or "." are ignored. These additional files can contain test functions, benchmark functions, and example functions. See 'go help testfunc' for more. Each listed package causes the execution of a separate test binary.

    The package is built in a temporary directory so it does not interfere with the non-test installation.

    Try running the benchmark tests in a program. For example,

    package main
    
    import (
        "fmt"
        "math"
        "testing"
    )
    
    // a function to be benchmarked
    func Area(r float64) float64 {
        return math.Pi * r * r
    }
    
    // benchmark function
    func BenchmarkArea(b *testing.B) {
        r := 42.0
        for i := 0; i < b.N; i++ {
            _ = Area(r)
        }
    }
    
    func main() {
        br := testing.Benchmark(BenchmarkArea)
        fmt.Println(br.String() + br.MemString())
    }
    

    Output:

    2000000000           1.21 ns/op       0 B/op           0 allocs/op
    

    Package testing

    func Benchmark

    func Benchmark(f func(b *B)) BenchmarkResult
    

    Benchmark benchmarks a single function. Useful for creating custom benchmarks that do not use the "go test" command.

    评论

报告相同问题?

悬赏问题

  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法