• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

manage cpu % during script

Explorer ,
Oct 14, 2022 Oct 14, 2022

Copy link to clipboard

Copied

hi, it s possible to survey the % cpu during a script? if over xx%, put script in pause?

TOPICS
Scripting

Views

91

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Oct 17, 2022 Oct 17, 2022

Actually you might check for CPU Usage. Here is a snippet from the IDS SDK but the same method can be found with InDesign Client : 

 

// Get the process cpu usage and vm statistics
	this.cpuTime = app.performanceMetric(PerformanceMetricOptions.CPU_TIME);
	this.sysCpuTime = app.performanceMetric(PerformanceMetricOptions.OVERALL_SYSTEM_CPU);
	this.userCpuTime = app.performanceMetric(PerformanceMetricOptions.OVERALL_USER_CPU);
	this.initVMSize = app.performanceMetric(PerformanceMetricOptions.VIRTUAL_
...

Likes

Translate

Translate
Community Expert ,
Oct 14, 2022 Oct 14, 2022

Copy link to clipboard

Copied

I don’t think so. You can look at the ExtendScript $ object API here:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#$.html

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 17, 2022 Oct 17, 2022

Copy link to clipboard

Copied

Actually you might check for CPU Usage. Here is a snippet from the IDS SDK but the same method can be found with InDesign Client : 

 

// Get the process cpu usage and vm statistics
	this.cpuTime = app.performanceMetric(PerformanceMetricOptions.CPU_TIME);
	this.sysCpuTime = app.performanceMetric(PerformanceMetricOptions.OVERALL_SYSTEM_CPU);
	this.userCpuTime = app.performanceMetric(PerformanceMetricOptions.OVERALL_USER_CPU);
	this.initVMSize = app.performanceMetric(PerformanceMetricOptions.VIRTUAL_MEMORY_SIZE);
	this.resMemSize = app.performanceMetric(PerformanceMetricOptions.RESIDENT_MEMORY_SIZE);

 

But Pausing a script might not be possible. You can exit your script though if you see the CPU go wild.

HTH

Loic

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 02, 2022 Nov 02, 2022

Copy link to clipboard

Copied

hi my idea is create an alert() is cpu is over 50%

 

i would like do same with memory?

into your code wich value is % of cpu?

 

because after 1hour of script, indesign continue to "crash" without reason

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 02, 2022 Nov 02, 2022

Copy link to clipboard

Copied

LATEST

I missed the application PerformanceMetricOptions. The full list is here:

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PerformanceMetricOptions.html

 

$.writeln(app.performanceMetric(PerformanceMetricOptions.CPU_TIME))
$.writeln(app.performanceMetric(PerformanceMetricOptions.OVERALL_SYSTEM_CPU))
$.writeln(app.performanceMetric(PerformanceMetricOptions.OVERALL_USER_CPU))

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines