Skip to content

Optimization question #257

Answered by ilopX
kirill-21 asked this question in Q&A
Jun 17, 2021 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

Hi @kirill-21!
Here is my benchmark.
Optimization works, 💪 but only slightly.

My results

Benchmark code

import 'dart:ffi';

import 'package:win32/win32.dart';

void main() {
  final benchmarks = runAllBenchmarks(passes: 100000);
  printAll(benchmarks);
}

List<Benchmark> runAllBenchmarks({required int passes}) {
  final defaultFuncName = 'GetAsyncKeyState()';
  final memorizedFuncName = 'MemorizedGetAsyncKeyState()';
  final key = 45 & 0x8000;

  return [
    Benchmark(defaultFuncName, 'load & first call', () {
      GetAsyncKeyState(key);
    }),
    Benchmark(defaultFuncName, 'second call', () {
      GetAsyncKeyState(key);
    }),
    Benchmark(defaultFuncName, 'third call', () …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@kirill-21
Comment options

@timsneath
Comment options

@ilopX
Comment options

@timsneath
Comment options

Answer selected by kirill-21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants