Пример #1
0
  /** 规定不区分线程的tid为0,被测程序的线程号为正数,GT控制台的线程号为负数 */
  public void startTime(long tid, String group, String tag, int exKey, long start, int funcId) {
    if (null != group && null != tag) {
      GroupTimeEntry groupEntry = groupMap.get(group);

      if (null == groupEntry) {
        groupEntry = new GroupTimeEntry(group);
        lock.lock();
        groupMap.put(group, groupEntry);
        lock.unlock();
      }

      // 从Group中取出由tag, tid, exKey共同标示的TagTimeEntry对象
      TagTimeEntry tagEntry = groupEntry.getThreadEntry(tag, tid, exKey);

      if (null == tagEntry) {
        tagEntry = new TagTimeEntry(groupEntry);
        tagEntry.setName(tag);
        tagEntry.setTid(tid);
        tagEntry.setExkey(exKey);
        /*
         * funcId用的是PERF_START_TIME_GLOBAL或PERF_START_DIGITAL_GLOBAL
         * 对于后面的使用只是保证UI精度,不会做其他依赖funcId的逻辑计算
         */
        tagEntry.setFunctionId(funcId);
        groupEntry.addEntry(tagEntry);
      }

      tagEntry.setLastStart(start);
    }
  }
Пример #2
0
  /** 记录单点的性能数据(start和end这种成对的称为双点性能数据),也按tid区分全局的还是线程的 */
  public void recordDigital(long tid, String group, String tag, long[] datas, int funcId) {
    if (!started) {
      return;
    }

    if (null != group && null != tag) {
      GroupTimeEntry groupEntry = groupMap.get(group);

      if (null == groupEntry) {
        groupEntry = new GroupTimeEntry(group);
        lock.lock();
        groupMap.put(group, groupEntry);
        lock.unlock();
      }

      // 从Group中取出由tag, tid共同标示的统计对象(exKey无用)
      TagTimeEntry staticsTagTimeEntry = groupEntry.getStaticsEntry(tag, tid);

      if (null == staticsTagTimeEntry) {
        staticsTagTimeEntry = new TagTimeEntry(groupEntry);
        staticsTagTimeEntry.setName(tag);
        staticsTagTimeEntry.setTid(tid);
        staticsTagTimeEntry.setFunctionId(funcId);
        staticsTagTimeEntry.initChildren(datas.length - 1);
        groupEntry.addStaticsEntry(staticsTagTimeEntry);
      }

      if (Functions.PERF_DIGITAL_MULT == funcId || Functions.PERF_DIGITAL_MULT_MEM == funcId) {
        TagTimeEntry[] subEntrys = staticsTagTimeEntry.getSubTagEntrys();
        for (int i = 0; i < subEntrys.length; i++) {
          TagTimeEntry subEntry = subEntrys[i];
          subEntry.add(datas[i]);
        }
        staticsTagTimeEntry.add(datas[0]); // TODO 得记录一个维度的值,否则外面UI无法展示
      } else {
        staticsTagTimeEntry.add(datas[0]);
      }
    }
  }