<commit_before>/*
 * Copyright 2012-2013 eBay Software Foundation and ios-driver committers
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package org.uiautomation.ios.utils;


import org.testng.IClass;
import org.testng.IMethodInstance;
import org.testng.IMethodInterceptor;
import org.testng.IResultMap;
import org.testng.ISuite;
import org.testng.ISuiteListener;
import org.testng.ISuiteResult;
import org.testng.ITestContext;
import org.testng.ITestNGMethod;
import org.testng.ITestResult;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class StatCollector implements ISuiteListener, IMethodInterceptor {


  private final Map<String, Long> timePerClass = new HashMap<>();
  private String suite;
  private boolean generate = false;
  private int nbSlave = 0;
  private Set<String> classesToRun = new HashSet<>();

  @Override
  public void onStart(ISuite suite) {
    String s = System.getProperty("generate");
//    System.out.println("THE PUTPUT IS : "+suite.getName());
//    System.exit(0);
    if (System.getProperty("generate") != null) {
      generate = true;
      nbSlave = Integer.parseInt(s);
    }
    this.suite = suite.getName();

    for (ITestNGMethod m : suite.getAllMethods()) {
      classesToRun.add(m.getTestClass().getRealClass().getCanonicalName());
    }

    if (generate) {
      for (ITestNGMethod m : suite.getExcludedMethods()) {
        System.out.println("EXCLUDED : " + m.getConstructorOrMethod().getMethod().toString());
      }

      try {
        split(nbSlave);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

  }

  class OldResultTime implements Comparable<OldResultTime> {

    private long duration;
    private String clazz;

    public OldResultTime(String clazz, int duration) {
      this.clazz = clazz;
      this.duration = duration;
    }


    @Override
    public int compareTo(OldResultTime o) {
      return (int) (o.duration - this.duration);
    }

    @Override
    public String toString() {
      return clazz + " (" + duration + ")";
    }

    public long getDuration() {
      return duration;
    }

    public String getClassCanonicalName() {
      return clazz;<commit_msg>tmp debug for the build<commit_after>/*
 * Copyright 2012-2013 eBay Software Foundation and ios-driver committers
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package org.uiautomation.ios.utils;


import org.testng.IClass;
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener2;
import org.testng.IMethodInstance;
import org.testng.IMethodInterceptor;
import org.testng.IResultMap;
import org.testng.ISuite;
import org.testng.ISuiteListener;
import org.testng.ISuiteResult;
import org.testng.ITestContext;
import org.testng.ITestNGMethod;
import org.testng.ITestResult;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class StatCollector implements ISuiteListener, IMethodInterceptor, IInvokedMethodListener2 {


  private final Map<String, Long> timePerClass = new HashMap<>();
  private String suite;
  private boolean generate = false;
  private int nbSlave = 0;
  private Set<String> classesToRun = new HashSet<>();

  @Override
  public void onStart(ISuite suite) {
    String s = System.getProperty("generate");
//    System.out.println("THE PUTPUT IS : "+suite.getName());
//    System.exit(0);
    if (System.getProperty("generate") != null) {
      generate = true;
      nbSlave = Integer.parseInt(s);
    }
    this.suite = suite.getName();

    for (ITestNGMethod m : suite.getAllMethods()) {
      classesToRun.add(m.getTestClass().getRealClass().getCanonicalName());
    }

    if (generate) {
      for (ITestNGMethod m : suite.getExcludedMethods()) {
        System.out.println("EXCLUDED : " + m.getConstructorOrMethod().getMethod().toString());
      }

      try {
        split(nbSlave);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

  }

  @Override
  public void beforeInvocation(IInvokedMethod method, ITestResult testResult,
                               ITestContext context) {
    System.out.println("about to run : " + method.toString());

  }

  @Override
  public void afterInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context) {
    System.out.println(
        "ran : " + method.toString() + " in " + (testResult.getEndMillis() - testResult
            .getStartMillis()) + "ms");

  }

  @Override
  public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {

  }

  @Override
  public void afterInvocation(IInvokedMethod method, ITestResult testResult) {

  }

  class OldResultTime implements Comparable<OldResultTime> {

    private long duration;
    private String clazz;

    public OldResultTime(String clazz, int duration) {
      this.clazz = clazz;
      this.duration = duration;
    }


    @Override
    public int compareTo(OldResultTime o) {
      return (int) (o.duration - this.duration);
    }

    @Override
    public String toString() {
      return clazz + " (" + duration + ")";
    }

    public long getDuration() {
      return duration;
    }

    public String getClassCanonicalName() {
      return clazz;
{'fraction_non_alphanumeric': 0.10394854920729883, 'fraction_numerical': 0.004486987735566856, 'mean_word_length': 3.5182432432432433, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '678629', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1939, 'n_words': 548}