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

manage cpu % during script

Explorer ,
Oct 14, 2022 Oct 14, 2022

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

TOPICS
Scripting
294
Translate
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

People's Champ , 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_
...
Translate
Community Expert ,
Oct 14, 2022 Oct 14, 2022

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

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

Translate
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
People's Champ ,
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_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

Translate
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

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

Translate
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
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))

 

Translate
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