Browse Source

perf: Update sleep threshold to 1000 instructions

Reduce sleep time for processing and output writing to 3s
Add html meta tag to force no cache for index.html
Lucas de Souza 2 years ago
parent
commit
ba3e12b53f
4 changed files with 11 additions and 11 deletions
  1. 3 3
      js/io/domConsole.js
  2. 2 2
      js/processor/ivprogProcessor.js
  3. 5 6
      js/util/config.ts
  4. 1 0
      templates/index.html

+ 3 - 3
js/io/domConsole.js

@@ -195,7 +195,7 @@ export class DOMConsole {
     // console.debug("Caling appendText");
     const write_time = Date.now();
     this.pending_writes.push(0);
-    await Utils.sleep(5);
+    await Utils.sleep(3);
     this.pending_writes.pop();
     if (this.last_clear >= write_time) {
       return;
@@ -219,7 +219,7 @@ export class DOMConsole {
   async _appendTextLn (text, type, filter = true) {
     const write_time = Date.now();
     this.pending_writes.push(0);
-    await Utils.sleep(5);
+    await Utils.sleep(3);
     this.pending_writes.pop();
     if (this.last_clear >= write_time) {
       return;
@@ -240,7 +240,7 @@ export class DOMConsole {
   async _appendUserInput (text) {
     const write_time = Date.now();
     this.pending_writes.push(0);
-    await Utils.sleep(5);
+    await Utils.sleep(3);
     this.pending_writes.pop();
     if (this.last_clear >= write_time) {
       return;

+ 2 - 2
js/processor/ivprogProcessor.js

@@ -374,7 +374,7 @@ export class IVProgProcessor {
     this.instruction_count += 1;
     if (this.instruction_count % Config.suspend_threshold == 0) {
       //every Config.suspend_threshold instruction should briefly delay its execution in order to allow the browser to process other things
-      await Utils.sleep(5);
+      await Utils.sleep(3);
     }
 
     // Checks if it must interrupt the execution for some reason
@@ -1038,7 +1038,7 @@ export class IVProgProcessor {
     this.instruction_count += 1;
     if (this.instruction_count % Config.suspend_threshold == 0) {
       //every Config.suspend_threshold instruction should briefly delay its execution in order to allow the browser to process other things
-      await Utils.sleep(5);
+      await Utils.sleep(3);
     }
     if (this.mode === Modes.ABORT) {
       throw LocalizedStrings.getMessage("aborted_execution");

+ 5 - 6
js/util/config.ts

@@ -2,8 +2,7 @@ interface ConfigInterface {
   [id: string]: unknown;
 }
 
-class ConfigObject implements ConfigInterface{
-
+class ConfigObject implements ConfigInterface {
   public decimalPlaces: number;
   public intConvertRoundMode: number;
   public default_lang: string;
@@ -16,10 +15,10 @@ class ConfigObject implements ConfigInterface{
   constructor () {
     this.decimalPlaces = 8;
     this.intConvertRoundMode = 2;
-    this.default_lang = 'pt';
+    this.default_lang = "pt";
     this.enable_type_casting = true;
     this.idle_input_interval = 5000;
-    this.suspend_threshold = 100;
+    this.suspend_threshold = 1000;
     // this.max_instruction_count = 350250; - automated evaluation limit
     this.max_instruction_count = Number.MAX_SAFE_INTEGER;
   }
@@ -27,7 +26,7 @@ class ConfigObject implements ConfigInterface{
   setConfig (opts: object): void {
     const otherConfig = opts as ConfigInterface;
     for (const key in otherConfig) {
-      if(Object.prototype.hasOwnProperty.call(this, key)){
+      if (Object.prototype.hasOwnProperty.call(this, key)) {
         this[key] = otherConfig[key];
       }
     }
@@ -35,4 +34,4 @@ class ConfigObject implements ConfigInterface{
 }
 
 const config = new ConfigObject();
-export const Config = config;
+export const Config = config;

+ 1 - 0
templates/index.html

@@ -2,6 +2,7 @@
 <html>
   <head>
     <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+    <meta http-equiv="Pragma" content="no-cache">
     <title></title>
     <link href="css/roboto.css" type="text/css" rel="stylesheet">
     <link rel="stylesheet" href="css/semantic.min.css"/>