<commit_before>package main

import (
	"runtime"
	"sync"
	"testing"

	"github.com/ready-steady/probability"
	"github.com/ready-steady/probability/uniform"

	"../internal"
)

func BenchmarkInvokeJobQueue(b *testing.B) {
	benchmarkInvoke(invokeJobQueue, b)
}

func BenchmarkInvokeNoJobQueue(b *testing.B) {
	benchmarkInvoke(invokeNoJobQueue, b)
}

func benchmarkInvoke(invoke func(internal.Target, []float64) []float64, b *testing.B) {
	const (
		sampleCount = 1000
	)

	config, _ := internal.NewConfig("fixtures/002_020_profile.json")
	problem, _ := internal.NewProblem(config)
	target, _ := internal.NewTarget(problem)

	ni, _ := target.Dimensions()

	points := probability.Sample(uniform.New(0, 1), sampleCount*ni)

	b.ResetTimer()

	for i := 0; i < b.N; i++ {
		invoke(target, points)
	}
}

func invokeJobQueue(target internal.Target, points []float64) []float64 {
	return internal.Invoke(target, points, uint(runtime.GOMAXPROCS(0)))
}

func invokeNoJobQueue(target internal.Target, points []float64) []float64 {
	ic, oc := target.Dimensions()<commit_msg>cmd/observe: fix the tests<commit_after>package main

import (
	"runtime"
	"sync"
	"testing"

	"github.com/ready-steady/probability"
	"github.com/ready-steady/probability/generator"
	"github.com/ready-steady/probability/uniform"

	"../internal"
)

func BenchmarkInvokeJobQueue(b *testing.B) {
	benchmarkInvoke(invokeJobQueue, b)
}

func BenchmarkInvokeNoJobQueue(b *testing.B) {
	benchmarkInvoke(invokeNoJobQueue, b)
}

func benchmarkInvoke(invoke func(internal.Target, []float64) []float64, b *testing.B) {
	const (
		sampleCount = 1000
	)

	config, _ := internal.NewConfig("fixtures/002_020_profile.json")
	problem, _ := internal.NewProblem(config)
	target, _ := internal.NewTarget(problem)

	ni, _ := target.Dimensions()

	points := probability.Sample(uniform.New(0, 1), generator.New(0), sampleCount*ni)

	b.ResetTimer()

	for i := 0; i < b.N; i++ {
		invoke(target, points)
	}
}

func invokeJobQueue(target internal.Target, points []float64) []float64 {
	return internal.Invoke(target, points, uint(runtime.GOMAXPROCS(0)))
}

func invokeNoJobQueue(target internal.Target, points []float64) []float64 {
	ic, oc := target.Dimensions()
{'fraction_non_alphanumeric': 0.1472196900638104, 'fraction_numerical': 0.02415679124886053, 'mean_word_length': 5.418128654970761, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5405658', 'n_tokens_mistral': 825, 'n_tokens_neox': 764, 'n_words': 142}