From 692293c6612c875e0f08066a7b2d1d89309ac042 Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Tue, 14 Nov 2023 16:52:40 +0800 Subject: [PATCH] test scalability for json lib --- timing_test.go | 188 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 timing_test.go diff --git a/timing_test.go b/timing_test.go new file mode 100644 index 000000000..84a900dc3 --- /dev/null +++ b/timing_test.go @@ -0,0 +1,188 @@ +// Copyright 2023 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package sonic + +import ( + "bytes" + "encoding/json" + "fmt" + "os" + "os/exec" + "runtime" + "strconv" + "sync" + "testing" + "time" +) + +func TestWork(t *testing.T) { + N, err := strconv.Atoi(os.Args[len(os.Args)-1]) + if err != nil { + return + } + p, err := strconv.Atoi(os.Args[len(os.Args)-2]) + if err != nil { + return + } + j := os.Args[len(os.Args)-3] + var obj = map[string]interface{}{} + for i:=0; i<100; i++ { + obj[strconv.Itoa(i)] = i + } + var work func() + if j == "sonic" { + work = func() { + for i:=0; i