Merge remote-tracking branch 'origin/GP-0_ryanmkurtz_timing--SQUASHED'

This commit is contained in:
Ryan Kurtz 2024-04-12 08:52:41 -04:00
commit 6c60bd0313
4 changed files with 20 additions and 7 deletions

View File

@ -27,12 +27,10 @@ import ghidra.base.help.GhidraHelpService;
import ghidra.framework.Application;
import ghidra.framework.GhidraApplicationConfiguration;
import ghidra.framework.client.RepositoryAdapter;
import ghidra.framework.data.DomainObjectAdapter;
import ghidra.framework.main.FrontEndTool;
import ghidra.framework.model.*;
import ghidra.framework.project.DefaultProjectManager;
import ghidra.framework.store.LockException;
import ghidra.program.database.ProgramDB;
import ghidra.util.*;
import ghidra.util.exception.UsrException;
import ghidra.util.extensions.ExtensionUtils;
@ -90,6 +88,9 @@ public class GhidraRun implements GhidraLaunchable {
SystemUtilities.runSwingLater(() -> {
String projectPath = processArguments(args);
openProject(projectPath);
log.info("Ghidra starup complete (" + GhidraLauncher.getMillisecondsFromLaunch() +
" ms)");
});
};

View File

@ -22,8 +22,7 @@ import java.net.URL;
import java.util.*;
import generic.stl.Pair;
import ghidra.GhidraApplicationLayout;
import ghidra.GhidraLaunchable;
import ghidra.*;
import ghidra.app.util.opinion.Loader;
import ghidra.framework.*;
import ghidra.framework.model.DomainFolder;
@ -118,6 +117,9 @@ public class AnalyzeHeadless implements GhidraLaunchable {
HeadlessOptions options = analyzer.getOptions();
parseOptions(options, args, optionStartIndex, ghidraURL, filesToImport);
Msg.info(AnalyzeHeadless.class,
"Headless startup complete (" + GhidraLauncher.getMillisecondsFromLaunch() + " ms)");
// Do the headless processing
try {
if (ghidraURL != null) {

View File

@ -273,8 +273,8 @@ public class ClassSearcher {
SystemUtilities.runSwingNow(() -> fireClassListChanged());
t = (new Date()).getTime() - t;
String finishedMessage = "Class search complete (" + t + " ms)";
String finishedMessage = "Class search complete (%d ms, %d classes loaded)"
.formatted((new Date()).getTime() - t, extensionPoints.size());
monitor.setMessage(finishedMessage);
log.info(finishedMessage);
}

View File

@ -17,6 +17,8 @@ package ghidra;
import java.io.*;
import java.lang.reflect.Constructor;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
@ -35,6 +37,8 @@ import utility.module.ModuleUtilities;
*/
public class GhidraLauncher {
private static Instant START_INSTANT = Instant.now();
/**
* Launches the given {@link GhidraLaunchable} specified in the first command line argument
*
@ -46,7 +50,6 @@ public class GhidraLauncher {
*/
public static void launch(String[] args) throws Exception {
// Initialize the Ghidra environment
GhidraApplicationLayout layout = initializeGhidraEnvironment();
// Make sure the thing to launch meets the criteria:
@ -93,6 +96,13 @@ public class GhidraLauncher {
launch(args);
}
/**
* {@return the current number of milliseconds that have elapsed since execution began}
*/
public static long getMillisecondsFromLaunch() {
return ChronoUnit.MILLIS.between(START_INSTANT, Instant.now());
}
/**
* Initializes the Ghidra environment by discovering its {@link GhidraApplicationLayout layout}
* and adding all relevant modules and libraries to the classpath