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

"Tearing off" a method is extremely slow #550

Closed
DartBot opened this issue Nov 21, 2011 · 1 comment
Closed

"Tearing off" a method is extremely slow #550

DartBot opened this issue Nov 21, 2011 · 1 comment
Labels
closed-invalid Closed as we don't believe the reported issue is generally actionable

Comments

@DartBot
Copy link

DartBot commented Nov 21, 2011

This issue was originally filed by [email protected]


The following code times two operations:

  1. call a closure that calls a method 'tearOff' on a particular object
  2. call a closure that returns a closure representing the object's 'tearOff' method, then call that closure

On my machine (Mac Pro, OS X 10.5.8) the second approach is about 1700 times slower.

class Test {
  Test();
  void tearOff() {}
}

class Benchmark {
  Test test;
  Function closure1;
  Function closure2;

  Benchmark();

  void run() {
    test = new Test();
    closure1 = () => test.tearOff();
    closure2 = () => test.tearOff;

    for (int iter = 0; iter < 10; iter++) {
      bench();
    }
  }
  
  void bench() {
    Stopwatch w1 = new Stopwatch();
    w1.start();
    for (int i = 0; i < 10000; i++) {
      closure1();
    }
    w1.stop;
    double t1 = w1.elapsedInUs() / 10000;
    
    Stopwatch w2 = new Stopwatch();
    w2.start();
    for (int i = 0; i < 10000; i++) {
      closure2()();
    }
    w2.stop;
    double t2 = w2.elapsedInUs() / 10000;

    print("$t1 $t2 ${t2 / t1}");
  }
}

void main() {
  new Benchmark().run();
}

@DartBot
Copy link
Author

DartBot commented Nov 21, 2011

This comment was originally written by [email protected]


Added Invalid label.

@DartBot DartBot added Type-Defect closed-invalid Closed as we don't believe the reported issue is generally actionable labels Nov 21, 2011
copybara-service bot pushed a commit that referenced this issue Jul 13, 2023
… native, protobuf, test, tools

Revisions updated by `dart tools/rev_sdk_deps.dart`.

dartdoc (https://github.com/dart-lang/dartdoc/compare/2522559..d716fa3):
  d716fa36  2023-07-13  Sam Rawlins  Migrate the try-publish and build-pub-package tasks to args commands (#3460)
  33b44d2d  2023-07-11  Sam Rawlins  Migrate doc-related tasks to package:args commands (#3459)

ecosystem (https://github.com/dart-lang/ecosystem/compare/b34db4f..db9d71d):
  db9d71d  2023-07-12  Devon Carew  upgrade to the latest stable action version (#133)
  3f4b8d1  2023-07-12  Moritz  Switch coverage computation (#132)
  5a9f06b  2023-07-10  Jacob MacDonald  add environment input to support github deployment environments (#131)
  f3b10c9  2023-07-10  Kevin Moore  blast_repo:auto-publish - add permissions by default (#129)

http (https://github.com/dart-lang/http/compare/c148a3a..b206771):
  b206771  2023-07-11  Brian Quinlan  Make native bindings pass `dart analysis` (#985)

leak_tracker (https://github.com/dart-lang/leak_tracker/compare/85bd7fb..5675231):
  5675231  2023-07-13  Polina Cherkasova  Add disconnection from service to free up references. (#91)
  9b97f84  2023-07-11  Parker Lougheed  Remove mentions to deprecated strong_mode options (#85)
  a21e90e  2023-07-11  Polina Cherkasova  Protect from identityHashCode equal to 0. (#90)
  8e3aa07  2023-07-11  Polina Cherkasova  Create troubleshooting helpers. (#89)

markdown (https://github.com/dart-lang/markdown/compare/b4bdde2..ee4e1b3):
  ee4e1b3  2023-07-13  Sam Rawlins  Bump to 7.1.1 (#550)

mockito (https://github.com/dart-lang/mockito/compare/451f756..ffbbb4c):
  ffbbb4c  2023-07-12  Ilya Yanok  Second attempt to fix "not found" error for type vars in bounds

native (https://github.com/dart-lang/native/compare/1e89ed9..acad396):
  acad396  2023-07-11  Daco Harkes  [infra] Remove the last path dependencies (#88)

protobuf (https://github.com/dart-lang/protobuf/compare/a912f76..d9e8a31):
  d9e8a31  2023-07-12  Kevin Moore  Compiler: generate doc comments (#860)

test (https://github.com/dart-lang/test/compare/3429712..a92b5bb):
  a92b5bb3  2023-07-12  Nate Bosch  Remove "compiling" messages (#2063)
  4e023035  2023-07-12  Nate Bosch  More loosely handle error message from SDK (#2064)

tools (https://github.com/dart-lang/tools/compare/af38b2b..765701d):
  765701d  2023-07-13  Elias Yishak  Enhance log file stats (#117)

Change-Id: Ib89e80f8f8963433c4abef953924830634352d86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313541
Auto-Submit: Devon Carew <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
osa1 pushed a commit to osa1/sdk that referenced this issue Jul 17, 2023
… native, protobuf, test, tools

Revisions updated by `dart tools/rev_sdk_deps.dart`.

dartdoc (https://github.com/dart-lang/dartdoc/compare/2522559..d716fa3):
  d716fa36  2023-07-13  Sam Rawlins  Migrate the try-publish and build-pub-package tasks to args commands (dart-lang#3460)
  33b44d2d  2023-07-11  Sam Rawlins  Migrate doc-related tasks to package:args commands (dart-lang#3459)

ecosystem (https://github.com/dart-lang/ecosystem/compare/b34db4f..db9d71d):
  db9d71d  2023-07-12  Devon Carew  upgrade to the latest stable action version (dart-lang#133)
  3f4b8d1  2023-07-12  Moritz  Switch coverage computation (dart-lang#132)
  5a9f06b  2023-07-10  Jacob MacDonald  add environment input to support github deployment environments (dart-lang#131)
  f3b10c9  2023-07-10  Kevin Moore  blast_repo:auto-publish - add permissions by default (dart-lang#129)

http (https://github.com/dart-lang/http/compare/c148a3a..b206771):
  b206771  2023-07-11  Brian Quinlan  Make native bindings pass `dart analysis` (dart-lang#985)

leak_tracker (https://github.com/dart-lang/leak_tracker/compare/85bd7fb..5675231):
  5675231  2023-07-13  Polina Cherkasova  Add disconnection from service to free up references. (dart-lang#91)
  9b97f84  2023-07-11  Parker Lougheed  Remove mentions to deprecated strong_mode options (dart-lang#85)
  a21e90e  2023-07-11  Polina Cherkasova  Protect from identityHashCode equal to 0. (dart-lang#90)
  8e3aa07  2023-07-11  Polina Cherkasova  Create troubleshooting helpers. (dart-lang#89)

markdown (https://github.com/dart-lang/markdown/compare/b4bdde2..ee4e1b3):
  ee4e1b3  2023-07-13  Sam Rawlins  Bump to 7.1.1 (dart-lang#550)

mockito (https://github.com/dart-lang/mockito/compare/451f756..ffbbb4c):
  ffbbb4c  2023-07-12  Ilya Yanok  Second attempt to fix "not found" error for type vars in bounds

native (https://github.com/dart-lang/native/compare/1e89ed9..acad396):
  acad396  2023-07-11  Daco Harkes  [infra] Remove the last path dependencies (dart-lang#88)

protobuf (https://github.com/dart-lang/protobuf/compare/a912f76..d9e8a31):
  d9e8a31  2023-07-12  Kevin Moore  Compiler: generate doc comments (dart-lang#860)

test (https://github.com/dart-lang/test/compare/3429712..a92b5bb):
  a92b5bb3  2023-07-12  Nate Bosch  Remove "compiling" messages (dart-lang#2063)
  4e023035  2023-07-12  Nate Bosch  More loosely handle error message from SDK (dart-lang#2064)

tools (https://github.com/dart-lang/tools/compare/af38b2b..765701d):
  765701d  2023-07-13  Elias Yishak  Enhance log file stats (dart-lang#117)

Change-Id: Ib89e80f8f8963433c4abef953924830634352d86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313541
Auto-Submit: Devon Carew <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-invalid Closed as we don't believe the reported issue is generally actionable
Projects
None yet
Development

No branches or pull requests

1 participant