Results of perf test on batchplay "get"

I know batchPlay is faster than the javascript API, but I was curious about the different flavors of the “get” command so here’s a quick perf test and not scientifically rigorous results…
I set up 4 tests, 1000 iterations each. I ran them on:

  1. A group with a mask and child layers

  2. A pixel layer

  3. An embedded smart object with style fx on it

    NOTES:

  • getDescriptorSync retrieves ALL properties of the layer using “get” (BatchPlay)
  • getPropertySync retrieves ONE specific property using “get” with target property (BatchPlay)
  • getPropertiesSync retrieves MULTIPLE specific properties using “multiget” with 3 target properties (BatchPlay )
  • The standard Photoshop DOM API retrieves ONE specific property

RESULTS (Group Folder)

  1. getDescriptorSync(layerRef)
    Total Time: 263.00ms

  2. getPropertySync(‘name’, layerRef)
    Total Time: 101.00ms

  3. getPropertiesSync([‘name’, ‘index’, ‘layerKind’], layerRef)
    Total Time: 104.00ms

  4. Native Photoshop API (photoshop.app.activeDocument.activeLayers[0].name)
    Total Time: 742.00ms

======================================================================

RESULTS (Pixel Layer)

  1. getDescriptorSync(layerRef)

  2. getPropertySync(‘name’, layerRef)

  3. getPropertiesSync([‘name’, ‘index’, ‘layerKind’], layerRef)

  4. Native Photoshop API (photoshop.app.activeDocument.activeLayers[0].name)

======================================================================

RESULTS (Smart Object w FX)

  1. getDescriptorSync(layerRef)
    Total Time: 657.00ms

  2. getPropertySync(‘name’, layerRef)
    Total Time: 76.00ms

  3. getPropertiesSync([‘name’, ‘index’, ‘layerKind’], layerRef)
    Total Time: 109.00ms

  4. Native Photoshop API (photoshop.app.activeDocument.activeLayers[0].name)
    Total Time: 576.00ms

======================================================================

Then ran it all through an AI analysis and here ya go!

Average Performance (across 3 different layer types):

1. getPropertySync: 0.0870ms per call :star: FASTEST

  • Group Folder: 0.1010ms
  • Pixel Layer: 0.0840ms
  • Smart Object: 0.0760ms

2. getPropertiesSync: 0.1087ms per call (1.25x slower)

  • Group Folder: 0.1040ms
  • Pixel Layer: 0.1130ms
  • Smart Object: 0.1090ms

3. getDescriptorSync: 0.5023ms per call (5.78x slower)

  • Group Folder: 0.2630ms
  • Pixel Layer: 0.5870ms
  • Smart Object: 0.6570ms

4. Native Photoshop API: 0.6293ms per call (7.24x slower)

  • Group Folder: 0.7420ms
  • Pixel Layer: 0.5700ms
  • Smart Object: 0.5760ms

Key Insights:

  1. getPropertySync is consistently fastest - winning in all 3 tests for single property access
  2. getPropertiesSync is only ~25% slower - excellent choice when you need 2-3 properties
  3. getDescriptorSync performance varies widely (0.26ms to 0.66ms) depending on layer complexity - slower for complex layers with more properties
  4. Native Photoshop API is surprisingly slow - averaging 7.24x slower than getPropertySync for the same single property access

Recommendation: Use getPropertySync for single properties, and getPropertiesSync when you need 2-4 properties. Only use getDescriptorSync when you need many properties (5+) to justify the performance cost.

I suppose I should show the BP descriptors, too. This is just chopped out of a larger codebase and won’t work as is.

const ref = getRef("layer");

// get full layer descriptor
const desc1: any = {
      _obj: "get",
      _target:
      {
        _ref: [ref],
      }
    };    

// get property
const desc2: any = {
      _obj: "get",
      _target:
      {
        _ref: [
          { _property: propName },
          ref
        ],
      }
    }; 

//get properties
const desc3: any = {
      _obj: "multiGet",
      _target: [ref],
      extendedReference: [properties],
      options: {
        failOnMissingProperty: false,
        failOnMissingElement: true,
      },
      _options: {
        dialogOptions: "dontDisplay",
      },
    };

// get property with API
const name = photoshop.app.activeDocument.activeLayers[0].name;

I believe you forgot to add pixel layer results :slightly_smiling_face:

DOM is slow because it had to do about 8-10 separated bp calls under the hood. Store layer instance and call only for name. So it does not check for document existence etc.