// Path: jandy-java-profiler/src/main/java/io/jandy/java/data/ThreadObject.java
// public class ThreadObject {
//   private long threadId;
//   private String threadName;
//   private String rootId;
// 
//   public String getThreadName() {
//     return threadName;
//   }
// 
//   public ThreadObject setThreadName(String threadName) {
//     this.threadName = threadName;
//     return this;
//   }
// 
//   public long getThreadId() {
//     return threadId;
//   }
// 
//   public ThreadObject setThreadId(long threadId) {
//     this.threadId = threadId;
//     return this;
//   }
// 
//   public String getRootId() {
//     return rootId;
//   }
// 
//   public ThreadObject setRootId(String rootId) {
//     this.rootId = rootId;
//     return this;
//   }
// 
// }
// 
// Path: jandy-java-profiler/src/main/java/io/jandy/java/profiler/ThreadContext.java
// public class ThreadContext {
//   private final DataObjectBuilder builder;
//   private TreeNode latest, root;
//   private ArrayCallStack treeNodes = new ArrayCallStack(128);
//   private ThreadObject thread = new ThreadObject();
// 
//   public ThreadContext(long threadId, String threadName, DataObjectBuilder builder) throws IOException {
//     this.thread.setThreadId(threadId);
//     this.thread.setThreadName(threadName);
//     this.builder = builder;
// 
//     this.latest = builder.getRootTreeNode();
//     this.root = this.latest;
//     this.thread.setRootId(this.root.getId());
// 
//     builder.save(this.latest);
//   }
// 
//   public void onMethodEnter(String className, int access, String methodName, String desc) {
//     treeNodes.push(latest);
// 
//     latest = this.builder.getTreeNode(className.replace('/', '.'), access, methodName, desc, latest.getId());
// 
//     latest.getAcc().setStartTime(System.nanoTime());
//   }
// 
//   public void onMethodExit(Throwable throwable) {
//     //    assert(latest.method.getName().equals(method.getName()));
//     //    assert(latest.method.getDescriptor().equals(method.getDescriptor()));
//     //    assert(latest.method.getAccess() == method.getAccess());
//     //    assert(latest.method.getOwner().getName().equals(owner.getName()));
//     //    assert(latest.method.getOwner().getPackageName().equals(owner.getPackageName()));
// 
//     long elapsedTime = System.nanoTime() - latest.getAcc().getStartTime();
//     latest.getAcc().setElapsedTime(latest.getAcc().getElapsedTime() + elapsedTime);
//     if (throwable != null)
//       latest.getAcc().setException(builder.getExceptionObject(throwable));
// 
//     long time = System.nanoTime();
//     builder.save(latest);
//     time = System.nanoTime() - time;
// 
//     latest = treeNodes.pop();
//     if (latest.getAcc() != null) {
//       latest.getAcc().setElapsedTime(latest.getAcc().getElapsedTime() - time);
//     }
//   }
// 
//   public void onExit() {
//     while (latest != root)
//       onMethodExit(null);
//   }
// 
//   public TreeNode getRoot() {
//     return root;
//   }
// 
//   public ThreadObject getThreadObject() {
//     return thread;
//   }
// }


import io.jandy.java.data.ThreadObject;
import io.jandy.java.data.TreeNode;
import io.jandy.java.profiler.ThreadContext;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package io.jandy.java;



/**
 * @author JCooky
 * @since 2016-06-07
 */
public class JandyProfilingContext {
  private ProfilingLogCollector collector;
  private long profId;

  public void start() throws IOException {
    String baseUrl = System.getProperty("jandy.base.url") + "/rest/travis";
    String sampleName = System.getProperty("jandy.sample.name");
    long batchSize = toBytes(System.getProperty("jandy.batch.size"));

    String repoSlug = System.getenv("TRAVIS_REPO_SLUG");
// Path: jandy-java-profiler/src/main/java/io/jandy/java/data/ThreadObject.java
// public class ThreadObject {
//   private long threadId;
//   private String threadName;
//   private String rootId;
// 
//   public String getThreadName() {
//     return threadName;
//   }
// 
//   public ThreadObject setThreadName(String threadName) {
//     this.threadName = threadName;
//     return this;
//   }
// 
//   public long getThreadId() {
//     return threadId;
//   }
// 
//   public ThreadObject setThreadId(long threadId) {
//     this.threadId = threadId;
//     return this;
//   }
// 
//   public String getRootId() {
//     return rootId;
//   }
// 
//   public ThreadObject setRootId(String rootId) {
//     this.rootId = rootId;
//     return this;
//   }
// 
// }
// 
// Path: jandy-java-profiler/src/main/java/io/jandy/java/profiler/ThreadContext.java
// public class ThreadContext {
//   private final DataObjectBuilder builder;
//   private TreeNode latest, root;
//   private ArrayCallStack treeNodes = new ArrayCallStack(128);
//   private ThreadObject thread = new ThreadObject();
// 
//   public ThreadContext(long threadId, String threadName, DataObjectBuilder builder) throws IOException {
//     this.thread.setThreadId(threadId);
//     this.thread.setThreadName(threadName);
//     this.builder = builder;
// 
//     this.latest = builder.getRootTreeNode();
//     this.root = this.latest;
//     this.thread.setRootId(this.root.getId());
// 
//     builder.save(this.latest);
//   }
// 
//   public void onMethodEnter(String className, int access, String methodName, String desc) {
//     treeNodes.push(latest);
// 
//     latest = this.builder.getTreeNode(className.replace('/', '.'), access, methodName, desc, latest.getId());
// 
//     latest.getAcc().setStartTime(System.nanoTime());
//   }
// 
//   public void onMethodExit(Throwable throwable) {
//     //    assert(latest.method.getName().equals(method.getName()));
//     //    assert(latest.method.getDescriptor().equals(method.getDescriptor()));
//     //    assert(latest.method.getAccess() == method.getAccess());
//     //    assert(latest.method.getOwner().getName().equals(owner.getName()));
//     //    assert(latest.method.getOwner().getPackageName().equals(owner.getPackageName()));
// 
//     long elapsedTime = System.nanoTime() - latest.getAcc().getStartTime();
//     latest.getAcc().setElapsedTime(latest.getAcc().getElapsedTime() + elapsedTime);
//     if (throwable != null)
//       latest.getAcc().setException(builder.getExceptionObject(throwable));
// 
//     long time = System.nanoTime();
//     builder.save(latest);
//     time = System.nanoTime() - time;
// 
//     latest = treeNodes.pop();
//     if (latest.getAcc() != null) {
//       latest.getAcc().setElapsedTime(latest.getAcc().getElapsedTime() - time);
//     }
//   }
// 
//   public void onExit() {
//     while (latest != root)
//       onMethodExit(null);
//   }
// 
//   public TreeNode getRoot() {
//     return root;
//   }
// 
//   public ThreadObject getThreadObject() {
//     return thread;
//   }
// }


// Path: jandy-java-profiler/src/main/java/io/jandy/java/JandyProfilingContext.java
import io.jandy.java.data.ThreadObject;
import io.jandy.java.data.TreeNode;
import io.jandy.java.profiler.ThreadContext;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

package io.jandy.java;



/**
 * @author JCooky
 * @since 2016-06-07
 */
public class JandyProfilingContext {
  private ProfilingLogCollector collector;
  private long profId;

  public void start() throws IOException {
    String baseUrl = System.getProperty("jandy.base.url") + "/rest/travis";
    String sampleName = System.getProperty("jandy.sample.name");
    long batchSize = toBytes(System.getProperty("jandy.batch.size"));

    String repoSlug = System.getenv("TRAVIS_REPO_SLUG");
    long buildId = Long.parseLong(System.getenv("TRAVIS_BUILD_ID"));