bedrocktool/subcommands/world/chunk_test.go

40 lines
899 B
Go
Raw Normal View History

2023-01-29 21:20:13 +00:00
package world_test
import (
2022-09-04 23:40:55 +00:00
"image/png"
"os"
"testing"
2023-01-29 21:20:13 +00:00
"github.com/bedrock-tool/bedrocktool/subcommands/world"
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/world/chunk"
)
2022-09-04 23:40:55 +00:00
func Test(t *testing.T) {
data, _ := os.ReadFile("chunk.bin")
ch, _, _ := chunk.NetworkDecode(33, data, 6, cube.Range{0, 255}, true, false)
2023-01-29 21:20:13 +00:00
i := world.Chunk2Img(ch)
2022-09-04 23:40:55 +00:00
f, _ := os.Create("chunk.png")
png.Encode(f, i)
f.Close()
}
func Benchmark_chunk_decode(b *testing.B) {
data, _ := os.ReadFile("chunk.bin")
for i := 0; i < b.N; i++ {
_, _, err := chunk.NetworkDecode(33, data, 6, cube.Range{0, 255}, true, false)
if err != nil {
b.Error(err)
}
}
}
func Benchmark_render_chunk(b *testing.B) {
data, _ := os.ReadFile("chunk.bin")
ch, _, _ := chunk.NetworkDecode(33, data, 6, cube.Range{0, 255}, true, false)
for i := 0; i < b.N; i++ {
2023-01-29 21:20:13 +00:00
world.Chunk2Img(ch)
}
}