forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
facebook#15.1 Extend packager server to receive signals from Sampling…
… Profiler Reviewed By: bestander Differential Revision: D3606098 fbshipit-source-id: ec55030dd1b3a27f0595650da1ce01fe1ac9116c
- Loading branch information
1 parent
684c3c1
commit 82ccdb0
Showing
3 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
|
||
module.exports = function(req, res, next) { | ||
if (req.url !== '/jsc-profile') { | ||
next(); | ||
return; | ||
} | ||
|
||
console.log('Dumping JSC profile information...'); | ||
const dumpName = '/tmp/jsc-profile_' + Date.now() + '.cpuprofile'; | ||
fs.writeFile(dumpName, req.rawBody, (err) => { | ||
var response = ''; | ||
if (err) { | ||
response = | ||
'An error occured when trying to save the profile at ' + dumpName; | ||
console.error(response, err); | ||
} else { | ||
response = | ||
'Your profile was generated at\n\n' + dumpName + '\n\n' + | ||
'Open `Chrome Dev Tools > Profiles > Load` ' | ||
+ 'and select the profile to visualize it.'; | ||
console.log(response); | ||
} | ||
res.end(response); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters