package bench

import (
	"os"
	"testing"
)

var LusScriptgetList = `
local key    = tostring(KEYS[1])
local keyss = redis.call("HGETALL", key)
local data = {}
local n = 1
for i, v in ipairs(keyss) do
	if i%2 == 0 then
		data[n] = redis.call("HGETALL", v)
		n = n+1
	end
end 
return data
`
var res string

func TestMain(m *testing.M) {
	defer os.Exit(m.Run())
}

func BenchmarkRedis(b *testing.B) {
	// uid := "2_62ec8ab8828fb7bf67b220b6"
	// heroRedisKey := fmt.Sprintf("hero_%s%s", uid, "{herotest}")
	var (
		// ncpu = runtime.NumCPU()
		parallelisms = []int{4, 16, 64}
		dataSizes    = []int{100, 1000, 10000}
		numKeys      = 1024
		// key          = heroRedisKey
		// keys         = []string{
		// 	"hero:0_62d6131a3a719b898a90b5fb-62d6131a3a719b898a90b5fe",
		// 	"hero:0_62d6131a3a719b898a90b5fb-62d6131a3a719b898a90b600",
		// 	"hero:0_62d6131a3a719b898a90b5fb-62d661d6bca6eab554879fc6",
		// 	"hero:0_62d6131a3a719b898a90b5fb-62d6694dbca6eab554879fef",
		// 	// "hero:0_62bbf14cf88fbd265e61a121-62bbf1849d64e5ee7ff12529",
		// 	// "hero:0_62bbf364f88fbd265e61a122-62bbf5189b1970ed6b28b638",
		// 	// "hero:0_62bbf364f88fbd265e61a122-62bbf5189b1970ed6b28b63e",
		// 	// "hero:0_62bbf57346a32c12466c2e64-62bbf58d9b1970ed6b28b643",
		// }
		builders = []TargetBuilder{
			{
				Name: "pipeline",
				Make: func(bench Benchmark) (Target, error) {

					return Target{
						Get: func() {

						},
					}, nil
				},
			},
			{
				Name: "lua",
				Make: func(bench Benchmark) (Target, error) {
					return Target{
						Get: func() {
						},
					}, nil
				},
			},
		}
	)

	RunBenchmark(b, compose(parallelisms, dataSizes, numKeys, builders))
}
