profile
This commit is contained in:
parent
5d5ae57cc9
commit
ef5c2ca337
|
@ -1,2 +1,4 @@
|
|||
region*.xml
|
||||
legendsbrowser
|
||||
*.pprof
|
||||
*.png
|
2
go.mod
2
go.mod
|
@ -5,5 +5,5 @@ go 1.18
|
|||
require (
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/iancoleman/strcase v0.2.0
|
||||
github.com/sa-/slicefunk v0.1.2
|
||||
github.com/pkg/profile v1.6.0
|
||||
)
|
||||
|
|
4
go.sum
4
go.sum
|
@ -2,5 +2,5 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
|||
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
|
||||
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
|
||||
github.com/sa-/slicefunk v0.1.2 h1:uTQiyKCTwc0RKNxXmG6NNlm3J1LF2hKmLgtf9kRAld4=
|
||||
github.com/sa-/slicefunk v0.1.2/go.mod h1:k0abNpV9EW8LIPl2+Hc9RiKsojKmsUhNNGFyMpjMTCI=
|
||||
github.com/pkg/profile v1.6.0 h1:hUDfIISABYI59DyeB3OTay/HxSRwTQ8rB/H83k6r5dM=
|
||||
github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18=
|
||||
|
|
12
main.go
12
main.go
|
@ -5,16 +5,26 @@ import (
|
|||
"legendsbrowser/model"
|
||||
"legendsbrowser/server"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"runtime"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/profile"
|
||||
)
|
||||
|
||||
var world model.World
|
||||
|
||||
func main() {
|
||||
defer profile.Start(profile.MemProfile).Stop()
|
||||
go func() {
|
||||
http.ListenAndServe(":8081", nil)
|
||||
}()
|
||||
|
||||
fmt.Println("Hallo Welt!")
|
||||
|
||||
world.Load("region1-00152-01-01-legends.xml")
|
||||
// world.Load("region1-00152-01-01-legends.xml")
|
||||
world.Load("region2-00195-01-01-legends.xml")
|
||||
runtime.GC()
|
||||
world.Process()
|
||||
|
||||
model.ListOtherElements(&world.HistoricalEvents)
|
||||
|
|
|
@ -3,7 +3,7 @@ package model
|
|||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"reflect"
|
||||
)
|
||||
|
@ -36,6 +36,10 @@ type World struct {
|
|||
EntityMap map[int]*Entity
|
||||
}
|
||||
|
||||
var cp437 = []byte(" \t\n \r !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ CueaaaaceeeiiiAAEaAooouuyOU faiounN ")
|
||||
|
||||
// var cp437 = []byte(" \t\n \r !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñÑ ")
|
||||
|
||||
func (w *World) Load(file string) {
|
||||
xmlFile, err := os.Open(file)
|
||||
if err != nil {
|
||||
|
@ -45,9 +49,14 @@ func (w *World) Load(file string) {
|
|||
fmt.Println("Successfully Opened users.xml")
|
||||
defer xmlFile.Close()
|
||||
|
||||
byteValue, _ := ioutil.ReadAll(xmlFile)
|
||||
byteValue, _ := io.ReadAll(xmlFile)
|
||||
fmt.Println(len(byteValue))
|
||||
|
||||
copy(byteValue[30:35], []byte("UTF-8"))
|
||||
for i := range byteValue {
|
||||
byteValue[i] = cp437[byteValue[i]]
|
||||
}
|
||||
|
||||
err = xml.Unmarshal(byteValue, w)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
|
|
Loading…
Reference in New Issue