iTwin / imodel-transformer

API for exporting an iModel's parts and also importing them into another iModel
MIT License
3 stars 2 forks source link

Performance scripts #36

Closed MichaelBelousov closed 1 year ago

MichaelBelousov commented 1 year ago

Add a "performance-scripts" package that can hook into most exported js functions and wrap profile generating logic around them. Currently all environment variable driven, explaining misusage and exiting immediately if you forget some.

Currently supported profile types are iTwin.js iModel sqlite profiling, linux perf profiling, JavaScript CPU profiling.

This allows you to do the following examples in this repo:

cd packages/test-app/

# profile the targetDb sqlite statements in the test app

PROFILE_TYPE=sqlite \
NODE_OPTIONS='-r ../performance-scripts' \
FUNCTIONS='require("./lib/Transformer").Transformer.transformAll' \
ARG_OFFSETS=1 \
node lib/Main.js \
  --sourceFile /tmp/samples/house_model.bim \
  --targetDestination /tmp/out.bim

# or separately profile both processAll and processSchemas native code performance with linux perf

PROFILE_TYPE=linux-perf \
NODE_OPTIONS='-r ../performance-scripts --perf-basic-prof --interpreted-frames-native-stack' \
FUNCTIONS='require("@itwin/imodel-transformer").IModelTransformer.prototype.processAll,require("@itwin/imodel-transformer").IModelTransformer.prototype.processSchemas'
sudo node lib/Main.js \
  --sourceFile /tmp/samples/house_model.bim \
  --targetDestination /tmp/out.bim

# or processSchemas js profile

PROFILE_TYPE=js-cpu \
NODE_OPTIONS='-r ../performance-scripts' \
FUNCTIONS='require("@itwin/imodel-transformer").IModelTransformer.prototype.processSchemas'
node lib/Main.js \
  --sourceFile /tmp/samples/house_model.bim \
  --targetDestination /tmp/out.bim
MichaelBelousov commented 1 year ago

I'm considering renaming the new package to hook-profilers or something... let me know if you have any thoughts reviewers