Пример #1
0
    private static JavaMethodProfile createMethodProfile(
        RawItemProfile<ResolvedJavaMethod> profile) {
      if (profile.entries <= 0 || profile.totalCount <= 0) {
        return null;
      }

      ProfiledMethod[] pmethods = new ProfiledMethod[profile.entries];
      double totalProbability = 0.0;
      for (int i = 0; i < profile.entries; i++) {
        double p = profile.counts[i];
        p = p / profile.totalCount;
        totalProbability += p;
        pmethods[i] = new ProfiledMethod(profile.items[i], p);
      }

      Arrays.sort(pmethods);

      double notRecordedMethodProbability =
          profile.entries < config.methodProfileWidth
              ? 0.0
              : Math.min(1.0, Math.max(0.0, 1.0 - totalProbability));
      assert notRecordedMethodProbability == 0 || profile.entries == config.methodProfileWidth;
      return new JavaMethodProfile(notRecordedMethodProbability, pmethods);
    }
Пример #2
0
    private static JavaTypeProfile createTypeProfile(
        TriState nullSeen, RawItemProfile<ResolvedJavaType> profile) {
      if (profile.entries <= 0 || profile.totalCount <= 0) {
        return null;
      }

      ProfiledType[] ptypes = new ProfiledType[profile.entries];
      double totalProbability = 0.0;
      for (int i = 0; i < profile.entries; i++) {
        double p = profile.counts[i];
        p = p / profile.totalCount;
        totalProbability += p;
        ptypes[i] = new ProfiledType(profile.items[i], p);
      }

      Arrays.sort(ptypes);

      double notRecordedTypeProbability =
          profile.entries < config.typeProfileWidth
              ? 0.0
              : Math.min(1.0, Math.max(0.0, 1.0 - totalProbability));
      assert notRecordedTypeProbability == 0 || profile.entries == config.typeProfileWidth;
      return new JavaTypeProfile(nullSeen, notRecordedTypeProbability, ptypes);
    }