{"ScriptPreparationCode":"var n = 1000000\r\nvar arr = new Array(n)\r\nfor(var i = 0; i \u003C n; i\u002B\u002B){\r\n arr[i] = i\r\n}\r\n\r\nclass Observer {\r\n\tconstructor() {\r\n \tthis.value = 0\r\n this.completed = false\r\n }\r\n \tnext (val) {\r\n \tthis.value\u002B=val\r\n }\r\n \tcomplete () {\r\n this.completed = true\r\n }\r\n}\r\n\r\n\r\nclass FromDirect {\r\n constructor (arr) {\r\n this.array = arr\r\n }\r\n sum (observer) {\r\n \tfor (var i = 0; i \u003C this.array.length; \u002B\u002Bi) {\r\n observer.next(this.array[i])\r\n }\r\n observer.complete()\r\n }\r\n}\r\n\r\nclass FromLater {\r\n constructor (arr) {\r\n this.array = arr\r\n }\r\n sum (observer) {\r\n \tfor (var i = 0; i \u003C this.array.length; \u002B\u002Bi) {\r\n observer.next(this.array[i])\r\n }\r\n end()\r\n function end () {\r\n observer.complete()\r\n }\r\n }\r\n}\r\nvar Ob0 = new Observer()\r\nvar Ob1 = new Observer()\r\n","TestCases":[{"Name":"Direct Call","Code":"var t0 = new FromDirect(arr)\r\nt0.sum(Ob0)","IsDeferred":false},{"Name":"Later Call","Code":"var t1 = new FromLater(arr)\r\nt1.sum(Ob1)","IsDeferred":false}]}