Skip to content

Support web platform#4

Open
hcanyz wants to merge 3 commits intoMidi12:masterfrom
hcanyz:master
Open

Support web platform#4
hcanyz wants to merge 3 commits intoMidi12:masterfrom
hcanyz:master

Conversation

@hcanyz
Copy link
Copy Markdown

@hcanyz hcanyz commented Aug 4, 2023

fix #3.

currently only available, performance is of magnitude worse than native.

I ran a rough performance test, use the following test method:

void main() {
  _benchmark();
}

void _benchmark() {
  final startTime = DateTime.now().millisecondsSinceEpoch;

  final Set<int> history = {};

  int conflictedCount = 0;
  for (int index = 0; index < 3000000; index++) {
    final id = createUniqueId();
    final exist = history.contains(id);
    if (exist) {
      debugPrint("$id $index conflicted.");
      conflictedCount++;
    }
    history.add(id);
  }

  debugPrint(
      "$conflictedCount ${history.length} ${DateTime.now().millisecondsSinceEpoch - startTime}");
}

int createUniqueId() {
  final fnv = fnv1a_64_s_bigint(const Uuid().v4());
  return (fnv & BigInt.from(0x1FFFFFFFFFFFFF)).toInt();
}

For the same device, it takes about 3 seconds for 3 million pieces of data on native, but it takes about 3 seconds for 30,000 pieces of data on the web platform.

Of course, there is a lot of time here to do other events, such as generating uuid, this is just a rough test.

hcanyz added 3 commits August 4, 2023 17:31
for supporting web platforms, currently only available, performance is two orders of magnitude worse than native.
@hcanyz
Copy link
Copy Markdown
Author

hcanyz commented Aug 22, 2023

@Midi12 Can it be merged? : )

@Midi12
Copy link
Copy Markdown
Owner

Midi12 commented Aug 23, 2023

@hcanyz Thank you for your contribution, I will be able to review it soon, I set up a reminder. I will notify you, thank you for your patience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

not support web

2 participants