Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

getMaxWorkers.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = getMaxWorkers;
  6. function _os() {
  7. const data = require('os');
  8. _os = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. /**
  14. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  15. *
  16. * This source code is licensed under the MIT license found in the
  17. * LICENSE file in the root directory of this source tree.
  18. */
  19. function getMaxWorkers(argv, defaultOptions) {
  20. if (argv.runInBand) {
  21. return 1;
  22. } else if (argv.maxWorkers) {
  23. return parseWorkers(argv.maxWorkers);
  24. } else if (defaultOptions && defaultOptions.maxWorkers) {
  25. return parseWorkers(defaultOptions.maxWorkers);
  26. } else {
  27. var _cpusInfo$length;
  28. // In watch mode, Jest should be unobtrusive and not use all available CPUs.
  29. const cpusInfo = (0, _os().cpus)();
  30. const numCpus =
  31. (_cpusInfo$length =
  32. cpusInfo === null || cpusInfo === void 0 ? void 0 : cpusInfo.length) !==
  33. null && _cpusInfo$length !== void 0
  34. ? _cpusInfo$length
  35. : 1;
  36. const isWatchModeEnabled = argv.watch || argv.watchAll;
  37. return Math.max(
  38. isWatchModeEnabled ? Math.floor(numCpus / 2) : numCpus - 1,
  39. 1
  40. );
  41. }
  42. }
  43. const parseWorkers = maxWorkers => {
  44. const parsed = parseInt(maxWorkers.toString(), 10);
  45. if (
  46. typeof maxWorkers === 'string' &&
  47. maxWorkers.trim().endsWith('%') &&
  48. parsed > 0 &&
  49. parsed <= 100
  50. ) {
  51. const numCpus = (0, _os().cpus)().length;
  52. const workers = Math.floor((parsed / 100) * numCpus);
  53. return Math.max(workers, 1);
  54. }
  55. return parsed > 0 ? parsed : 1;
  56. };