Skip to content

Conversation

@dpohvar
Copy link

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