github.com/thommil/tge-gl@v0.0.0-20190313100017-83d8f10f8fae/gl_test.go (about) 1 // Copyright (c) 2019 Thomas MILLET. All rights reserved. 2 package gl 3 4 import ( 5 "testing" 6 ) 7 8 func TestPointerToBytes(t *testing.T) { 9 10 } 11 12 const NB_POLYGONS = 1000 13 14 func BenchmarkUint16ToBytes(b *testing.B) { 15 uint16Array := make([]uint16, NB_POLYGONS*6) 16 b.ResetTimer() 17 for i := 0; i < b.N; i++ { 18 Uint16ToBytes(uint16Array) 19 } 20 } 21 22 func BenchmarkUint32ToBytes(b *testing.B) { 23 uint32Array := make([]uint32, NB_POLYGONS*6) 24 b.ResetTimer() 25 for i := 0; i < b.N; i++ { 26 Uint32ToBytes(uint32Array) 27 } 28 } 29 30 func BenchmarkFloat32ToBytes(b *testing.B) { 31 float32Array := make([]float32, NB_POLYGONS*3) 32 b.ResetTimer() 33 for i := 0; i < b.N; i++ { 34 Float32ToBytes(float32Array) 35 } 36 } 37 38 func BenchmarkFloat64ToBytes(b *testing.B) { 39 float64Array := make([]float64, NB_POLYGONS*3) 40 b.ResetTimer() 41 for i := 0; i < b.N; i++ { 42 Float64ToBytes(float64Array) 43 } 44 } 45 46 func BenchmarkPointerToBytesByte(b *testing.B) { 47 uintByteArray := make([]byte, NB_POLYGONS*6) 48 b.ResetTimer() 49 for i := 0; i < b.N; i++ { 50 PointerToBytes(&uintByteArray[0], len(uintByteArray)) 51 } 52 } 53 54 func BenchmarkPointerToBytesUINT16(b *testing.B) { 55 uint16Array := make([]uint16, NB_POLYGONS*6) 56 b.ResetTimer() 57 for i := 0; i < b.N; i++ { 58 PointerToBytes(&uint16Array[0], len(uint16Array)) 59 } 60 } 61 62 func BenchmarkPointerToBytesUINT32(b *testing.B) { 63 uint32Array := make([]uint32, NB_POLYGONS*6) 64 b.ResetTimer() 65 for i := 0; i < b.N; i++ { 66 PointerToBytes(&uint32Array[0], len(uint32Array)) 67 } 68 } 69 70 func BenchmarkPointerToBytesFLOAT32(b *testing.B) { 71 float32Array := make([]float32, NB_POLYGONS*3) 72 b.ResetTimer() 73 for i := 0; i < b.N; i++ { 74 PointerToBytes(&float32Array[0], len(float32Array)) 75 } 76 } 77 78 func BenchmarkPointerToBytesFLOAT64(b *testing.B) { 79 float64Array := make([]float64, NB_POLYGONS*3) 80 b.ResetTimer() 81 for i := 0; i < b.N; i++ { 82 PointerToBytes(&float64Array[0], len(float64Array)) 83 } 84 }