Jump to content

Recommended Posts

Posted

 

Recently we had an user asking how much disk I/O certain script steps cause and whether we can see how much FileMaker writes or reads from disk.

In MBS FileMaker Plugin 15.3 we added a new SystemInfo.AppResourceUsageStatistics function for macOS to query various statistics and return them as JSON.

You can query:

  • CPU Time
  • Memory usage
  • Neural engine memory
  • Instruction counters
  • Energy use 
  • Disk i/O
  • Wakeups
  • Pageing counters

We can take a direct look on the statistics before doing an action and after the action. We see directly the CPU time spend for how many instructions, the memory allocated and whatever disk reads or writes happen.

Let's test this with an example:

Set Variable [ $json1 ; Value: MBS( "SystemInfo.AppResourceUsageStatistics" ) ]
Set Variable [ $logical_writes1 ; Value: JSONGetElement ( $json1 ; "logical_writes" ) ]
Set Variable [ $diskio_byteswritten1 ; Value: JSONGetElement ( $json1 ; "diskio_byteswritten" ) ]
# 
Set Field [ Kontakte::Firma ; "Hello World" ]
# 
Set Variable [ $json2 ; Value: MBS( "SystemInfo.AppResourceUsageStatistics" ) ]
Set Variable [ $logical_writes2 ; Value: JSONGetElement ( $json2 ; "logical_writes" ) ]
Set Variable [ $diskio_byteswritten2 ; Value: JSONGetElement ( $json2 ; "diskio_byteswritten" ) ]
# 
Commit Records/Requests [ With dialog: Off ]
# 
Set Variable [ $json3 ; Value: MBS( "SystemInfo.AppResourceUsageStatistics" ) ]
Set Variable [ $logical_writes3 ; Value: JSONGetElement ( $json3 ; "logical_writes" ) ]
Set Variable [ $diskio_byteswritten3 ; Value: JSONGetElement ( $json3 ; "diskio_byteswritten" ) ]
# 
Flush Cache to Disk
# 
Set Variable [ $json4 ; Value: MBS( "SystemInfo.AppResourceUsageStatistics" ) ]
Set Variable [ $logical_writes4 ; Value: JSONGetElement ( $json4 ; "logical_writes" ) ]
Set Variable [ $diskio_byteswritten4 ; Value: JSONGetElement ( $json4 ; "diskio_byteswritten" ) ]

In data viewer we get the numbers

$logical_writes4	185131016
$logical_writes3	185106440
$logical_writes2	185106440
$logical_writes1	185106440
$diskio_byteswritten4	57192448
$diskio_byteswritten3	57147392
$diskio_byteswritten2	57147392
$diskio_byteswritten1	57147392

Which tells us, that for this call, the whole commit happens only in memory. It's a local file, so FileMaker defers the write to get multiple writes together. We need to flush cache to actually get the writes to happen.

We can calculate that we caused about 24 KB on the logical size, but then got a few more blocks written as physical size:

185131016 - 185106440 = 24576 Bytes
57192448  - 57147392  = 45056 Bytes

Depending on how FileMaker writes, it may write to the same block multiple times and the OS only flushes the affected blocks with a delay. 

In summary, with SystemInfo.AppResourceUsageStatistics, you can:

  • Monitor how your scripts impact CPU, memory, and energy.
  • Track disk I/O in real-time.
  • Profile performance of complex scripts or plug-in actions.
  • Understand QoS (Quality of Service) level CPU usage.

Please try with the new plugin version.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.