`stdJSON` parse performance
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 30/100
- Tipo di issue
- Refactoring
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- json
- Ambito
- performance
Direzione di ricerca
Start at stdJSON.CreateFromString and run the supplied parsing and stringification benchmarks against JsonConverter and JsonBag. Review how stdJSON stores children, including the IDispatch-based Dictionary, and evaluate the proposed in-class array and hash-table design. Done means the parsing benchmark improves without regressing the existing stringification result.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Current benchmarks
Parsing
Parsing is probably one of the most important metrics. Generally people parse json more than they do make it. So this is an important metric.
Test code
Const cmax As Long = 100
With stdJSON.Create()
For i = 1 To 100
With .AddObject("x" & i)
.Add "x", "x"
.Add "y", 100
.Add "longString", String$(255, "x")
With .AddArray("test")
.Add 1
.Add 2
.Add 3
End With
End With
Next
Dim s As String: s = .ToString()
End With
With stdPerformance.Measure("JsonConverter", cmax)
For i = 1 To cmax
Call JsonConverter.ParseJson(s)
Next
End With
With stdPerformance.Measure("JsonBag", cmax)
For i = 1 To cmax
Dim x As JsonBag
Set x = New JsonBag
x.JSON = s
Next
End With
With stdPerformance.Measure("stdJSON", cmax)
For i = 1 To cmax
Call stdJSON.CreateFromString(s)
Next
End With
Results
JsonConverter: 5641 ms (56410µs per operation)
JsonBag: 2891 ms (28910µs per operation)
stdJSON: 7234 ms (72340µs per operation)
From these results we can see that stdJSON is significantly slower at the moment than Either Tim Hall's JSON module and JsonBag.
I think JsonBag is likely getting the performance it does by using 2 collections to store it's children data? Though this is unconfirmed. This is something that needs improving in stdJSON!
Next steps
My anticipation is that if we migrate stdJSON to use a in-class Array and HashTable (instead of IDispatch based Dictionary) this will be significantly faster than the current implementation. I.E.
Type TChild
key as string
val as variant
next as long
prev as long
End Type
Type TThis
hashes(0 to 255) as Long
children as TChild
End Type
Stringification
For completeness, stringification is less important but is still a useful benchmark.
Test code
Const cmax As Long = 10
With stdJSON.Create()
For i = 1 To 1000
With .AddObject("x" & i)
.Add "x", "x"
.Add "y", 100
.Add "longString", String$(255, "x")
With .AddArray("test")
.Add 1
.Add 2
.Add 3
End With
End With
Next
Dim s As String: s = .ToString()
End With
With stdPerformance.Optimise
Dim timHallJSON As Object: Set timHallJSON = JsonConverter.ParseJson(s)
Dim jsBag As New JsonBag: jsBag.JSON = s
Dim std As stdJSON: Set std = stdJSON.CreateFromString(s)
Dim x As String
With stdPerformance.Measure("JsonConverter", cmax)
For i = 1 To cmax
x = JsonConverter.ConvertToJson(timHallJSON)
Next
End With
With stdPerformance.Measure("JsonBag", cmax)
For i = 1 To cmax
x = jsBag.JSON
Next
End With
With stdPerformance.Measure("stdJSON", cmax)
For i = 1 To cmax
x = std.ToString
Next
End With
End With
Results
JsonConverter: 4328 ms (432800µs per operation)
JsonBag: 10578 ms (1057800µs per operation)
stdJSON: 422 ms (42200µs per operation)
As we can see stdJSON is much better than the competition here, so at least we have something right. I think this is largely because both JSONConverter and JsonBag commonly use str = left(str, len(str)-1) to handle trailing commas, which when dealing with huge strings is incredibly slow! Instead we prevent the trailing commas from being in the string in the first place. Perhaps a better solution however is leave the trailing commas alone, and trim our buffer by subtracting 1 from the buffer index after the last operation...
Next steps
Consider allowing trailing commas, and removing the commas just by subtracting 1 from the buffer index.
- Lingua principale
- VBA
- Stelle
- 412
- Fork
- 70
- Merge medio
- 16h 10m
- PR unite (30g)
- 3
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di sancarn/stdVBA
-
stdDate.WeekdayName raises type mismatch and ignores explicit first day during Weekday lookupAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
-
Issues of stdRefArrayApertaenhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
Tutte le issue di sancarn/stdVBA
Issue simili
-
3.0.0-M*: every channel stays reachable from its session's KEX listeners, so a long-lived session leaks all closed channelsForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
OpenMathLib/OpenBLAS#6192 ·
I maintainer di solito rispondono entro 1 giorno
-
Edge children regression test from #797 has a 2x margin under llvm-cov and passes under --releaseApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
tox-dev/pipdeptree#840 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
grafana/pyroscope-dotnet#470 ·
I maintainer di solito rispondono entro 1 giorno
-
pending-maintainer-response pending-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
aws-amplify/amplify-ui#7201 ·
I maintainer di solito rispondono entro 2 giorni