protected void perfValidate(String filename, int iterations) throws Exception { // read in the file InputStream in = FileLocator.openStream( Platform.getBundle(JSCorePlugin.PLUGIN_ID), Path.fromPortableString("performance/" + filename), false); IFile file = project.createFile(filename, IOUtil.read(in)); RebuildIndexJob job = new RebuildIndexJob(project.getURI()); job.run(null); // Ok now actually validate the thing, the real work for (int i = 0; i < iterations; i++) { EditorTestHelper.joinBackgroundActivities(); BuildContext context = new BuildContext(file); // Don't measure reading in string... context.getContents(); startMeasuring(); validator.buildFile(context, null); stopMeasuring(); } commitMeasurements(); assertPerformance(); }
protected void perfValidate(String filename, int iterations) throws Exception { // read in the file URL url = FileLocator.find( Platform.getBundle(JSCorePlugin.PLUGIN_ID), Path.fromPortableString("performance/" + filename), null); File file = ResourceUtil.resourcePathToFile(url); IFileStore fileStore = EFS.getStore(file.toURI()); // Ok now actually validate the thing, the real work for (int i = 0; i < iterations; i++) { EditorTestHelper.joinBackgroundActivities(); // Force a re-parse every time so we're comparing apples to apples for JSLint BuildContext context = new FileStoreBuildContext(fileStore) { @Override protected ParseResult parse( String contentType, IParseState parseState, WorkingParseResult working) throws Exception { if (reparseEveryTime()) { return new JSParser().parse(parseState); } return super.parse(contentType, parseState, working); } }; // Don't measure reading in string... context.getContents(); startMeasuring(); validator.buildFile(context, null); stopMeasuring(); } commitMeasurements(); assertPerformance(); }