SamplingProfiler.js 996 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @format
  8. * @flow strict-local
  9. */
  10. 'use strict';
  11. const SamplingProfiler = {
  12. poke: function(token: number): void {
  13. let error = null;
  14. let result = null;
  15. try {
  16. result = global.pokeSamplingProfiler();
  17. if (result === null) {
  18. console.log('The JSC Sampling Profiler has started');
  19. } else {
  20. console.log('The JSC Sampling Profiler has stopped');
  21. }
  22. } catch (e) {
  23. console.log(
  24. 'Error occurred when restarting Sampling Profiler: ' + e.toString(),
  25. );
  26. error = e.toString();
  27. }
  28. const NativeJSCSamplingProfiler = require('./NativeJSCSamplingProfiler')
  29. .default;
  30. if (NativeJSCSamplingProfiler) {
  31. NativeJSCSamplingProfiler.operationComplete(token, result, error);
  32. }
  33. },
  34. };
  35. module.exports = SamplingProfiler;