From b318ee171af7c02e9fa543e67322c6c2ec8b1133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=92=D0=B0=D1=85?= =?UTF-8?q?=D1=82=D1=91=D1=80=D0=BE=D0=B2?= Date: Wed, 22 May 2019 14:23:52 +0500 Subject: [PATCH 1/2] proposal-use-slow-directive --- proposal-use-slow-directive.md | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 proposal-use-slow-directive.md diff --git a/proposal-use-slow-directive.md b/proposal-use-slow-directive.md new file mode 100644 index 0000000..f15bcbb --- /dev/null +++ b/proposal-use-slow-directive.md @@ -0,0 +1,54 @@ +# ECMAScript proposal: The "use slow" Directive +- [Motivation](#motivation) +- [Declaring](#declaring) +- [Usage](#usage) + +## 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: +```js +"use slow"; +console.log('slow code'); +``` + +At the beginning of a function: +```js +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. Example: +```js +"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: +```js +"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'); + } +} +``` \ No newline at end of file From 2d8e9178adc985e214cffc887977e820f37cefa5 Mon Sep 17 00:00:00 2001 From: Andrey Vakhterov Date: Wed, 22 May 2019 14:27:37 +0500 Subject: [PATCH 2/2] fix usage text --- proposal-use-slow-directive.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proposal-use-slow-directive.md b/proposal-use-slow-directive.md index f15bcbb..cbb3ee3 100644 --- a/proposal-use-slow-directive.md +++ b/proposal-use-slow-directive.md @@ -30,7 +30,7 @@ function slowFunction(){ `"use slow";` affects only the function in which it is declared. ## Usage -Use slow can be be more than once. Example: +Use slow can be be more than once. Slowdown effect is multiplied. Example: ```js "use slow"; // x 2 "use slow"; // x 2 @@ -51,4 +51,4 @@ function f(){ console.log('this code 8 times slower'); } } -``` \ No newline at end of file +```