# Profiling

The code below uses YourKit's controll classes to create a snapshot.

    			    public void testProfilePluginScripts() throws Exception {
    			        String docString = "<DR_ShortCreateIntervalRecords><factId>219250542869</factId><longDescr>REEE</longDescr></DR_ShortCreateIntervalRecords>";
    			        Document doc = DocumentHelper.parseText(docString);

    			        // warmups
    			        for (int i = 0; i < 5; i++) {
    			            BusinessObjectDispatcher.execute(doc, BusinessObjectActionLookup.constants.FAST_UPDATE);
    			            rollbackAndContinue();
    			        }

    			        Controller controller = new Controller();
    			        controller.forceGC();
    			        controller.startCPUProfiling(ProfilingModes.CPU_SAMPLING, Controller.DEFAULT_FILTERS);
    			        for (int i = 0; i < 500; i++) {
    			            BusinessObjectDispatcher.execute(doc, BusinessObjectActionLookup.constants.FAST_UPDATE);
    			            rollbackAndContinue();
    			        }
    			        controller.captureSnapshot(ProfilingModes.SNAPSHOT_WITHOUT_HEAP);
    			    }

Parent topic: Optimization and Performance Profiling