Skip to content
This repository has been archived by the owner on Feb 4, 2025. It is now read-only.

Json benchmarks #52

Merged
merged 3 commits into from
Aug 30, 2024
Merged

Conversation

davidmorgan
Copy link
Contributor

@davidmorgan davidmorgan commented Aug 26, 2024

These are the benchmarks I was using while writing JsonBufferBuilder.

The output is not particularly stable, as you can see from the variation over three runs, full output below. But it's enough for approximate work :)

       SdkMapsJsonWireBenchmark: 1455ms, 6108907 bytes
     SdkMapsBufferWireBenchmark: 1518ms, 4409017 bytes
    SdkMapsBuilderWireBenchmark: 1359ms, 4159021 bytes
    BufferMapsJsonWireBenchmark:  883ms, 6108907 bytes
  BufferMapsBufferWireBenchmark:  369ms, 4409017 bytes
   BuilderMapsJsonWireBenchmark: 1049ms, 6108907 bytes
BuilderMapsBuilderWireBenchmark:  167ms, 1509126 bytes

     ProcessSdkMapsJsonWireBenchmark:  397ms, hash 289171379
  ProcessBufferMapsJsonWireBenchmark:  312ms, hash 289171379
 ProcessBuilderMapsJsonWireBenchmark:  311ms, hash 289171379

Deserialized output validated.

       SdkMapsJsonWireBenchmark: 1600ms, 6108907 bytes
     SdkMapsBufferWireBenchmark: 1300ms, 4409017 bytes
    SdkMapsBuilderWireBenchmark: 1216ms, 4159021 bytes
    BufferMapsJsonWireBenchmark:  843ms, 6108907 bytes
  BufferMapsBufferWireBenchmark:  354ms, 4409017 bytes
   BuilderMapsJsonWireBenchmark:  987ms, 6108907 bytes
BuilderMapsBuilderWireBenchmark:  152ms, 1509126 bytes

     ProcessSdkMapsJsonWireBenchmark:  321ms, hash 289171379
  ProcessBufferMapsJsonWireBenchmark:  302ms, hash 289171379
 ProcessBuilderMapsJsonWireBenchmark:  303ms, hash 289171379

Deserialized output validated.

       SdkMapsJsonWireBenchmark: 1260ms, 6108907 bytes
     SdkMapsBufferWireBenchmark: 1175ms, 4409017 bytes
    SdkMapsBuilderWireBenchmark: 1255ms, 4159021 bytes
    BufferMapsJsonWireBenchmark:  834ms, 6108907 bytes
  BufferMapsBufferWireBenchmark:  357ms, 4409017 bytes
   BuilderMapsJsonWireBenchmark:  954ms, 6108907 bytes
BuilderMapsBuilderWireBenchmark:  153ms, 1509126 bytes

     ProcessSdkMapsJsonWireBenchmark:  321ms, hash 289171379
  ProcessBufferMapsJsonWireBenchmark:  322ms, hash 289171379
 ProcessBuilderMapsJsonWireBenchmark:  300ms, hash 289171379

Deserialized output validated.

@davidmorgan davidmorgan force-pushed the json-benchmarks branch 2 times, most recently from 5286f15 to b8598c0 Compare August 27, 2024 14:33
@davidmorgan davidmorgan marked this pull request as ready for review August 29, 2024 08:44
@davidmorgan davidmorgan requested a review from jakemac53 August 29, 2024 08:45
isField: (intKey & 8) == 8,
isMethod: (intKey & 16) == 16,
isStatic: (intKey & 32) == 32));
members['a'] = _makeMember('a');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we create unique names, so that we actually encode more strings in the object and not just a ton of pointers? Just in case that matters, because in practice most members wont have the same names.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, done, this also addresses "member names won't be known in advance".

import 'serialization_benchmark.dart';

/// Benchmark accumulating data into a [JsonBuffer] via [LazyMap].
class BufferMapsBufferWireBenchmark extends SerializationBenchmark {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: include LazyMap in the name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

pkgs/dart_model/benchmark/main.dart Show resolved Hide resolved
@davidmorgan
Copy link
Contributor Author

Thanks! Output after changes

       SdkMapsJsonWireBenchmark: 1646ms, 7177227 bytes
     SdkMapsBufferWireBenchmark: 1423ms, 5122684 bytes
    SdkMapsBuilderWireBenchmark: 1492ms, 4859868 bytes
      LazyMapsJsonWireBenchmark:  939ms, 7177227 bytes
    LazyMapsBufferWireBenchmark:  568ms, 5122684 bytes
   BuilderMapsJsonWireBenchmark: 1386ms, 7177227 bytes
BuilderMapsBuilderWireBenchmark:  360ms, 2111773 bytes

     ProcessSdkMapsJsonWireBenchmark:  379ms, hash 23186292
  ProcessLazyMapsBufferWireBenchmark:  233ms, hash 23186292
ProcessBuilderMapsBuilderWireBenchmark:  302ms, hash 23186292

Deserialized output validated.

       SdkMapsJsonWireBenchmark: 2208ms, 7177227 bytes
     SdkMapsBufferWireBenchmark: 2032ms, 5122684 bytes
    SdkMapsBuilderWireBenchmark: 2160ms, 4859868 bytes
      LazyMapsJsonWireBenchmark: 1254ms, 7177227 bytes
    LazyMapsBufferWireBenchmark:  602ms, 5122684 bytes
   BuilderMapsJsonWireBenchmark: 1493ms, 7177227 bytes
BuilderMapsBuilderWireBenchmark:  365ms, 2111773 bytes

     ProcessSdkMapsJsonWireBenchmark:  453ms, hash 23186292
  ProcessLazyMapsBufferWireBenchmark:  250ms, hash 23186292
ProcessBuilderMapsBuilderWireBenchmark:  299ms, hash 23186292

Deserialized output validated.

       SdkMapsJsonWireBenchmark: 1578ms, 7177227 bytes
     SdkMapsBufferWireBenchmark: 1527ms, 5122684 bytes
    SdkMapsBuilderWireBenchmark: 1905ms, 4859868 bytes
      LazyMapsJsonWireBenchmark: 1176ms, 7177227 bytes
    LazyMapsBufferWireBenchmark:  564ms, 5122684 bytes
   BuilderMapsJsonWireBenchmark: 1411ms, 7177227 bytes
BuilderMapsBuilderWireBenchmark:  349ms, 2111773 bytes

     ProcessSdkMapsJsonWireBenchmark:  378ms, hash 23186292
  ProcessLazyMapsBufferWireBenchmark:  246ms, hash 23186292
ProcessBuilderMapsBuilderWireBenchmark:  307ms, hash 23186292

Deserialized output validated.

@davidmorgan davidmorgan merged commit 2bf45de into dart-archive:main Aug 30, 2024
43 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants