Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support web platform #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Support web platform #4

wants to merge 3 commits into from

Conversation

hcanyz
Copy link

@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.

for supporting web platforms, currently only available, performance is two orders of magnitude worse than native.
@hcanyz
Copy link
Author

hcanyz commented Aug 22, 2023

@Midi12 Can it be merged? : )

@Midi12
Copy link
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