// Path: dali/src/main/java/at/favre/lib/dali/util/BenchmarkUtil.java
// public final class BenchmarkUtil {
//     private static final DecimalFormat format = new DecimalFormat("#.0");
//     private static final String fileSeperator = ";";
// 
//     static {
//         format.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ENGLISH));
//         format.setRoundingMode(RoundingMode.HALF_UP);
//     }
// 
//     private BenchmarkUtil() {
//     }
// 
//     public static long elapsedRealTimeNanos() {
//         if (Build.VERSION.SDK_INT >= 17) {
//             return SystemClock.elapsedRealtimeNanos();
//         }
//         return SystemClock.elapsedRealtime() * 1000000L;
//     }
// 
//     public static String formatNum(double number) {
//         return format.format(number);
//     }
// 
//     public static String formatNum(double number, String formatString) {
//         final DecimalFormat format = new DecimalFormat(formatString);
//         format.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ENGLISH));
//         format.setRoundingMode(RoundingMode.HALF_UP);
//         return format.format(number);
//     }
// 
//     public static String getScalingUnitByteSize(int byteSize) {
//         double scaledByteSize = (double) byteSize;
//         String unit = "byte";
// 
//         if (scaledByteSize < 1024) {
//             return formatNum(scaledByteSize, "0.##") + unit;
//         } else {
//             unit = "KiB";
//             scaledByteSize /= 1024d;
// 
//             if (scaledByteSize < 1024) {
//                 return formatNum(scaledByteSize, "0.##") + unit;
//             } else {
//                 unit = "MiB";
//                 scaledByteSize /= 1024d;
//                 if (scaledByteSize < 1024) {
//                     return formatNum(scaledByteSize, "0.##") + unit;
//                 } else {
//                     unit = "GiB";
//                     scaledByteSize /= 1024d;
//                     return formatNum(scaledByteSize, "0.##") + unit;
//                 }
//             }
//         }
//     }
// 
//     public static String getCurrentTime() {
//         SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss.SSS", Locale.getDefault());
//         return sdf.format(new Date());
//     }
// }


import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import at.favre.lib.dali.util.BenchmarkUtil;
package at.favre.lib.dali.builder;




/**
 * A simple Profiler that helps in measuring parts of code.
 * <p>
 * This will use nano seconds (if possible with SDK)
 */
public class PerformanceProfiler {
    private static final String TAG = PerformanceProfiler.class.getSimpleName();

    private String description;
    private List<Duration> durations;
    private boolean isActivated;

    public PerformanceProfiler(String description) {
        this(description, true);
    }

    /**
     * @param description describes the task
     * @param isActivated if this is false, every call to a method will do exactly nothing to
     *                    avoid to have unnecessary overhead
     */
    public PerformanceProfiler(String description, boolean isActivated) {
        this.description = description;
        this.durations = new ArrayList<Duration>();
        this.isActivated = isActivated;
    }

    /**
     * Start a task. The id is needed to end the task
     *
     * @param id
     * @param taskName
     */
    public void startTask(int id, String taskName) {
        if (isActivated) {
// Path: dali/src/main/java/at/favre/lib/dali/util/BenchmarkUtil.java
// public final class BenchmarkUtil {
//     private static final DecimalFormat format = new DecimalFormat("#.0");
//     private static final String fileSeperator = ";";
// 
//     static {
//         format.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ENGLISH));
//         format.setRoundingMode(RoundingMode.HALF_UP);
//     }
// 
//     private BenchmarkUtil() {
//     }
// 
//     public static long elapsedRealTimeNanos() {
//         if (Build.VERSION.SDK_INT >= 17) {
//             return SystemClock.elapsedRealtimeNanos();
//         }
//         return SystemClock.elapsedRealtime() * 1000000L;
//     }
// 
//     public static String formatNum(double number) {
//         return format.format(number);
//     }
// 
//     public static String formatNum(double number, String formatString) {
//         final DecimalFormat format = new DecimalFormat(formatString);
//         format.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ENGLISH));
//         format.setRoundingMode(RoundingMode.HALF_UP);
//         return format.format(number);
//     }
// 
//     public static String getScalingUnitByteSize(int byteSize) {
//         double scaledByteSize = (double) byteSize;
//         String unit = "byte";
// 
//         if (scaledByteSize < 1024) {
//             return formatNum(scaledByteSize, "0.##") + unit;
//         } else {
//             unit = "KiB";
//             scaledByteSize /= 1024d;
// 
//             if (scaledByteSize < 1024) {
//                 return formatNum(scaledByteSize, "0.##") + unit;
//             } else {
//                 unit = "MiB";
//                 scaledByteSize /= 1024d;
//                 if (scaledByteSize < 1024) {
//                     return formatNum(scaledByteSize, "0.##") + unit;
//                 } else {
//                     unit = "GiB";
//                     scaledByteSize /= 1024d;
//                     return formatNum(scaledByteSize, "0.##") + unit;
//                 }
//             }
//         }
//     }
// 
//     public static String getCurrentTime() {
//         SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss.SSS", Locale.getDefault());
//         return sdf.format(new Date());
//     }
// }


// Path: dali/src/main/java/at/favre/lib/dali/builder/PerformanceProfiler.java
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import at.favre.lib.dali.util.BenchmarkUtil;

package at.favre.lib.dali.builder;




/**
 * A simple Profiler that helps in measuring parts of code.
 * <p>
 * This will use nano seconds (if possible with SDK)
 */
public class PerformanceProfiler {
    private static final String TAG = PerformanceProfiler.class.getSimpleName();

    private String description;
    private List<Duration> durations;
    private boolean isActivated;

    public PerformanceProfiler(String description) {
        this(description, true);
    }

    /**
     * @param description describes the task
     * @param isActivated if this is false, every call to a method will do exactly nothing to
     *                    avoid to have unnecessary overhead
     */
    public PerformanceProfiler(String description, boolean isActivated) {
        this.description = description;
        this.durations = new ArrayList<Duration>();
        this.isActivated = isActivated;
    }

    /**
     * Start a task. The id is needed to end the task
     *
     * @param id
     * @param taskName
     */
    public void startTask(int id, String taskName) {
        if (isActivated) {
            durations.add(new Duration(id, taskName, BenchmarkUtil.elapsedRealTimeNanos()));