33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import { virtualMachineHint } from 'vs/base/node/id' ;
7- import * as os from 'os' ;
86import { IElectronService } from 'vs/platform/electron/electron-sandbox/electron' ;
97import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService' ;
108import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService' ;
@@ -18,6 +16,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
1816import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility' ;
1917import { IStartupMetrics , AbstractTimerService , Writeable } from 'vs/workbench/services/timer/browser/timerService' ;
2018import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
19+ import { context , process } from 'vs/base/parts/sandbox/electron-sandbox/globals' ;
2120
2221export class TimerService extends AbstractTimerService {
2322
@@ -49,12 +48,18 @@ export class TimerService extends AbstractTimerService {
4948
5049 protected async _extendStartupInfo ( info : Writeable < IStartupMetrics > ) : Promise < void > {
5150 try {
52- info . totalmem = os . totalmem ( ) ;
53- info . freemem = os . freemem ( ) ;
54- info . platform = os . platform ( ) ;
55- info . release = os . release ( ) ;
56- info . arch = os . arch ( ) ;
57- info . loadavg = os . loadavg ( ) ;
51+ const [ osProperties , osStatistics , virtualMachineHint ] = await Promise . all ( [
52+ this . _electronService . getOSProperties ( ) ,
53+ this . _electronService . getOSStatistics ( ) ,
54+ this . _electronService . getOSVirtualMachineHint ( )
55+ ] ) ;
56+
57+ info . totalmem = osStatistics . totalmem ;
58+ info . freemem = osStatistics . freemem ;
59+ info . platform = osProperties . platform ;
60+ info . release = osProperties . release ;
61+ info . arch = osProperties . arch ;
62+ info . loadavg = osStatistics . loadavg ;
5863
5964 const processMemoryInfo = await process . getProcessMemoryInfo ( ) ;
6065 info . meminfo = {
@@ -63,9 +68,9 @@ export class TimerService extends AbstractTimerService {
6368 sharedBytes : processMemoryInfo . shared
6469 } ;
6570
66- info . isVMLikelyhood = Math . round ( ( virtualMachineHint . value ( ) * 100 ) ) ;
71+ info . isVMLikelyhood = Math . round ( ( virtualMachineHint * 100 ) ) ;
6772
68- const rawCpus = os . cpus ( ) ;
73+ const rawCpus = osProperties . cpus ;
6974 if ( rawCpus && rawCpus . length > 0 ) {
7075 info . cpus = { count : rawCpus . length , speed : rawCpus [ 0 ] . speed , model : rawCpus [ 0 ] . model } ;
7176 }
@@ -78,8 +83,12 @@ export class TimerService extends AbstractTimerService {
7883//#region cached data logic
7984
8085export function didUseCachedData ( ) : boolean {
86+ // TODO@Ben TODO@Jo need a different way to figure out if cached data was used
87+ if ( context . sandbox ) {
88+ return true ;
89+ }
8190 // We surely don't use cached data when we don't tell the loader to do so
82- if ( ! Boolean ( ( < any > global ) . require . getConfig ( ) . nodeCachedData ) ) {
91+ if ( ! Boolean ( ( < any > window ) . require . getConfig ( ) . nodeCachedData ) ) {
8392 return false ;
8493 }
8594 // There are loader events that signal if cached data was missing, rejected,
0 commit comments