Skip to content

Instantly share code, notes, and snippets.

@rcarmo
rcarmo / benchmark.py
Last active December 16, 2015 06:49
Go benchmark
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Main application script
Created by: Rui Carmo
License: MIT (see LICENSE for details)
"""
import os, sys

Problems & Solutions for Interaction Between C and Go

At Vimeo, on the transcoding team, we work a lot with Go, and a lot with C, for various tasks such as media ingest. This means we use CGO quite extensively, and consequently, have run into bits that are perhaps not very well documented, if at all. Below is my effort to document some of the problems we've run into, and how we fixed or worked around them.

Many of these are obviously wrong in retrospect, but hindsight is 20/20, and these problems do exist in many codebases currently.

Some are definitely ugly, and I much welcome better solutions! Tweet me at @daemon404 if you have any, or have your own CGO story/tips, please! I'd love to learn of them.

Table of Contents

@tmc
tmc / gist:f1364bcee04d1192278dd2f297cf116f
Last active June 19, 2021 21:47
Pure Go VRF implementation benchmarking
goos: linux
goarch: amd64
pkg: github.com/algorand/go-algorand/crypto
cpu: Intel(R) Xeon(R) CPU @ 2.30GHz
BenchmarkVrfVerifyGo-2 signal: interrupt
FAIL github.com/algorand/go-algorand/crypto 1.863s
goos: linux
goarch: amd64
pkg: github.com/algorand/go-algorand/crypto
cpu: Intel(R) Xeon(R) CPU @ 2.30GHz