github.com/matrixorigin/matrixone@v1.2.0/pkg/vectorize/sum/sum_test.go (about) 1 // Copyright 2021 Matrix Origin 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package sum 16 17 import ( 18 "fmt" 19 "testing" 20 ) 21 22 func makeIbuffer(l int) []int64 { 23 buf := make([]int64, l) 24 for i := range buf { 25 buf[i] = int64(i) 26 } 27 return buf 28 } 29 30 func makeFbuffer(l int) []float64 { 31 buf := make([]float64, l) 32 for i := range buf { 33 buf[i] = float64(i) 34 } 35 return buf 36 } 37 38 func TestF64Sum(t *testing.T) { 39 xs := makeFbuffer(10000) 40 fmt.Printf("sum: %v\n", Float64Sum(xs)) 41 fmt.Printf("pure sum: %v\n", floatSum(xs)) 42 } 43 44 func TestI64Sum(t *testing.T) { 45 xs := makeIbuffer(10000) 46 fmt.Printf("sum: %v\n", Int64Sum(xs)) 47 fmt.Printf("pure sum: %v\n", signedSum(xs)) 48 }