refactor: replace json with json-iterator/go to improve performance

This commit is contained in:
debugtalk
2022-03-04 17:39:15 +08:00
parent 54431f205b
commit ce4c3d414e
12 changed files with 37 additions and 13 deletions

View File

@@ -1,7 +1,6 @@
package boomer
import (
"encoding/json"
"fmt"
"os"
"sort"
@@ -13,6 +12,8 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/push"
"github.com/rs/zerolog/log"
"github.com/httprunner/hrp/internal/json"
)
// Output is primarily responsible for printing test results to different destinations

View File

@@ -1,8 +1,9 @@
package boomer
import (
"encoding/json"
"time"
"github.com/httprunner/hrp/internal/json"
)
type transaction struct {

View File

@@ -5,7 +5,6 @@ import (
"crypto/md5"
"encoding/csv"
"encoding/hex"
"encoding/json"
"fmt"
"math"
"math/rand"
@@ -15,9 +14,10 @@ import (
"strings"
"time"
"github.com/rs/zerolog/log"
"gopkg.in/yaml.v3"
"github.com/rs/zerolog/log"
"github.com/httprunner/hrp/internal/json"
)
var Functions = map[string]interface{}{

View File

@@ -2,7 +2,6 @@ package har2case
import (
"encoding/base64"
"encoding/json"
"fmt"
"io"
"net/url"
@@ -17,6 +16,7 @@ import (
"github.com/httprunner/hrp"
"github.com/httprunner/hrp/internal/builtin"
"github.com/httprunner/hrp/internal/ga"
"github.com/httprunner/hrp/internal/json"
)
const (

14
internal/json/json.go Normal file
View File

@@ -0,0 +1,14 @@
package json
import (
jsoniter "github.com/json-iterator/go"
)
var json = jsoniter.ConfigCompatibleWithStandardLibrary
var (
Marshal = json.Marshal
MarshalIndent = json.MarshalIndent
Unmarshal = json.Unmarshal
NewDecoder = json.NewDecoder
)