정확히는 모르겠지만 adb 명령을 통해 콘솔에서 작업을 하는 것과
java 에서 많은 depth를 거쳐 wrapping 된 명령은 같은 명령이라 할지라도 속도 차가 좀 나지 않을까요?
추측성이지만 실제 tcpdump 산출 시간은 같으나 wrapping된 인터페이스에서 발생하는 객체 생성/삭제 메서드 호출 등이 느려지게 하지 않나 싶어요.
콘솔과 비슷하게 하려면 depth를 최대한 줄여서 tcpdump 를 수행하는 c코드를 작성하는 것이 어떨지요..?
아래는 실제 exec(...) 메서드 호출 시 ProcessManager 에서 수행하는 부분입니다. (젤리빈)
public Process exec(String[] taintedCommand, String[] taintedEnvironment, File workingDirectory, boolean redirectErrorStream)
throws IOException
{
if (taintedCommand == null) {
throw new NullPointerException("taintedCommand == null");
}
if (taintedCommand.length == 0) {
throw new IndexOutOfBoundsException("taintedCommand.length == 0");
}
String[] command = (String[])taintedCommand.clone();
String[] environment = taintedEnvironment != null ? (String[])taintedEnvironment.clone() : null;
for (int i = 0; i < command.length; i++) {
if (command[i] == null) {
throw new NullPointerException("taintedCommand[" + i + "] == null");
}
}
if (environment != null) {
for (int i = 0; i < environment.length; i++) {
if (environment[i] == null) {
throw new NullPointerException("taintedEnvironment[" + i + "] == null");
}
}
}
FileDescriptor in = new FileDescriptor();
FileDescriptor out = new FileDescriptor();
FileDescriptor err = new FileDescriptor();
String workingPath = workingDirectory == null ? null : workingDirectory.getPath();
synchronized (this.processReferences) {
int pid;
try {
pid = exec(command, environment, workingPath, in, out, err, redirectErrorStream);
} catch (IOException e) {
IOException wrapper = new IOException("Error running exec(). Command: " + Arrays.toString(command) + " Working Directory: " + workingDirectory + " Environment: " + Arrays.toString(environment));
wrapper.initCause(e);
throw wrapper;
}
ProcessImpl process = new ProcessImpl(pid, in, out, err);
ProcessReference processReference = new ProcessReference(process, this.referenceQueue);
this.processReferences.put(Integer.valueOf(pid), processReference);
this.processReferences.notifyAll();
return process;
}
}