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

ECMAScript proposal: "use slow" directive. #4

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

Conversation

DPOH-VAR
Copy link

@DPOH-VAR DPOH-VAR commented May 22, 2019

ECMAScript proposal: The "use slow" Directive

Motivation

"use slow"; defines that code should be executed slowly.
Basic performance decrease: x 2.

Declaring

"use slow"; Must be declared in a Directive Prologue

At the beginning of a script:

"use slow";
console.log('slow code');

At the beginning of a function:

console.log('normal');

function slowFunction(){
  "use slow";
  console.log('slow');
}

"use slow"; affects only the function in which it is declared.

Usage

Use slow can be be more than once. Slowdown effect is multiplied. Example:

"use slow"; // x 2
"use slow"; // x 2
"use slow"; // x 2
console.log('this code 8 times slower');

Use slow inside the function takes effect from the outside code or function:

"use slow"; // x 2
console.log('this code 2 times slower');

function f(){
  "use slow"; // x 2
  console.log('this code 4 times slower');
  
  return function g(){
    "use slow"; // x 2
    console.log('this code 8 times slower');
  }
}

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.

2 participants