{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/readable-stream/issues/158","labels_url":"https://api.github.com/repos/nodejs/readable-stream/issues/158/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/readable-stream/issues/158/comments","events_url":"https://api.github.com/repos/nodejs/readable-stream/issues/158/events","html_url":"https://github.com/nodejs/readable-stream/pull/158","id":107226386,"number":158,"title":"Move require out of constructor to top of module","user":{"login":"borisovg","id":3171327,"avatar_url":"https://avatars.githubusercontent.com/u/3171327?v=3","gravatar_id":"","url":"https://api.github.com/users/borisovg","html_url":"https://github.com/borisovg","followers_url":"https://api.github.com/users/borisovg/followers","following_url":"https://api.github.com/users/borisovg/following{/other_user}","gists_url":"https://api.github.com/users/borisovg/gists{/gist_id}","starred_url":"https://api.github.com/users/borisovg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/borisovg/subscriptions","organizations_url":"https://api.github.com/users/borisovg/orgs","repos_url":"https://api.github.com/users/borisovg/repos","events_url":"https://api.github.com/users/borisovg/events{/privacy}","received_events_url":"https://api.github.com/users/borisovg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-18T15:41:50Z","updated_at":"2015-09-18T15:44:19Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nodejs/readable-stream/pulls/158","html_url":"https://github.com/nodejs/readable-stream/pull/158","diff_url":"https://github.com/nodejs/readable-stream/pull/158.diff","patch_url":"https://github.com/nodejs/readable-stream/pull/158.patch"},"body":"This provides a big performance improvement.\r\n\r\nThe Stream module code in current Node no longer has this issue."},"comment":{"url":"https://api.github.com/repos/nodejs/readable-stream/issues/comments/141486623","html_url":"https://github.com/nodejs/readable-stream/pull/158#issuecomment-141486623","issue_url":"https://api.github.com/repos/nodejs/readable-stream/issues/158","id":141486623,"user":{"login":"borisovg","id":3171327,"avatar_url":"https://avatars.githubusercontent.com/u/3171327?v=3","gravatar_id":"","url":"https://api.github.com/users/borisovg","html_url":"https://github.com/borisovg","followers_url":"https://api.github.com/users/borisovg/followers","following_url":"https://api.github.com/users/borisovg/following{/other_user}","gists_url":"https://api.github.com/users/borisovg/gists{/gist_id}","starred_url":"https://api.github.com/users/borisovg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/borisovg/subscriptions","organizations_url":"https://api.github.com/users/borisovg/orgs","repos_url":"https://api.github.com/users/borisovg/repos","events_url":"https://api.github.com/users/borisovg/events{/privacy}","received_events_url":"https://api.github.com/users/borisovg/received_events","type":"User","site_admin":false},"created_at":"2015-09-18T15:44:19Z","updated_at":"2015-09-18T15:44:19Z","body":"## Benchmark results:\r\n\r\n```\r\n100000 reps in 12735524135 ns (7852 ops/s)\r\n\r\nvs\r\n\r\n100000 reps in 3121319649 ns (32037 ops/s)\r\n```\r\n\r\n## Test environment:\r\n\r\n```\r\n{ http_parser: '2.5.0',\r\n  node: '4.0.0',\r\n  v8: '4.5.103.30',\r\n  uv: '1.7.3',\r\n  zlib: '1.2.8',\r\n  ares: '1.10.1-DEV',\r\n  modules: '46',\r\n  openssl: '1.0.2d' }\r\n```\r\n\r\n## Benchmark code\r\n\r\n```\r\nvar Writable = require('readable-stream/writable');\r\n\r\nvar i, startTime,\r\n    reps = 100000,\r\n    semaphore = reps;\r\n\r\nfunction _make_socket () {\r\n    var data = [],\r\n        ws = new Writable();\r\n\r\n    ws._write = function (chunk, encoding, next) {\r\n        data.push(chunk.toString());\r\n        next();\r\n    };\r\n\r\n    ws.on('finish', function () {\r\n        var d;\r\n\r\n        d = data.join('');\r\n\r\n        semaphore -= 1;\r\n\r\n        if (!semaphore) {\r\n            end(startTime);\r\n        }\r\n    });\r\n\r\n    return ws;\r\n}\r\n\r\nstartTime = process.hrtime();\r\n\r\nfor (i = 0; i < reps; i += 1) {\r\n    var ws = _make_socket();\r\n\r\n    ws.end(new Buffer('foo'));\r\n}\r\n\r\nfunction end (startTime) {\r\n    var diff = process.hrtime(startTime);\r\n    var ns = diff[0] * 1e9 + diff[1];\r\n    var s = diff[0] + diff[1] * 1e-9;\r\n\r\n    console.log('%d reps in %d ns (%d ops/s)', reps, ns, Math.floor(reps / s));\r\n    console.log(process.versions);\r\n}\r\n```"}}