Example usage for java.util.concurrent.atomic LongAdder add

List of usage examples for java.util.concurrent.atomic LongAdder add

Introduction

In this page you can find the example usage for java.util.concurrent.atomic LongAdder add.

Prototype

public void add(long x) 

Source Link

Document

Adds the given value.

Usage

From source file:com.webtide.jetty.load.generator.jenkins.LoadGeneratorBuildAction.java

public LoadGeneratorBuildAction(HealthReport health, SummaryReport summaryReport,
        CollectorInformations globalResponseTimeInformations,
        CollectorInformations globalLatencyTimeInformations,
        Map<String, List<ResponseTimeInfo>> allResponseInfoTimePerPath, Run<?, ?> run,
        Map<String, Object> monitoringResultMap, String xmlStats) {
    this.health = health;
    this.summaryReport = summaryReport;
    this.globalResponseTimeInformations = globalResponseTimeInformations;
    this.globalLatencyTimeInformations = globalLatencyTimeInformations;
    this.jobName = run.getParent().getName();
    this.allResponseInfoTimePerPath = allResponseInfoTimePerPath;
    this.buildId = run.getId();
    this.monitoringResultMap = monitoringResultMap;
    this.xmlStats = xmlStats;
    for (List<ResponseTimeInfo> responseTimeInfos : allResponseInfoTimePerPath.values()) {
        for (ResponseTimeInfo info : responseTimeInfos) {
            int statusFamily = info.getStatus() / 100;
            LongAdder longAdder = responseNumberPerStatusFamily.get(statusFamily);
            if (longAdder == null) {
                longAdder = new LongAdder();
                responseNumberPerStatusFamily.put(statusFamily, longAdder);
            }/*from  ww w  . jav a 2  s.c o  m*/
            longAdder.add(1);
        }
    }

}

From source file:edu.rit.flick.DefaultFlickFile.java

@Override
public File inflate(final Configuration configuration, final File fileIn, final File fileOut) {
    try {/*from   w  ww  .  ja  v  a  2 s  . c o m*/
        if (!getDefaultDeflatedExtension().endsWith(Files.getFileExtension(fileIn.getName()))) {
            final File decompressedFile = archiveFile(fileIn, true);

            if (decompressedFile != null && configuration.getFlag(DELETE_FLAG))
                if (!FileUtils.deleteQuietly(fileIn))
                    System.err.printf(FILE_COULD_NOT_BE_DELETED_WARNING_FORMAT, fileIn.getPath());

            return decompressedFile;
        }

        final LongAdder unzippedContentsSize = new LongAdder();

        final long inputFileSize = FileUtils.sizeOf(fileIn);
        final long t0 = System.currentTimeMillis();

        flickFile.extractAll(fileOut.getPath());

        final RandomAccessFile raf = new RandomAccessFile(flickFile.getFile(), InternalZipConstants.READ_MODE);

        final HeaderReader hr = new HeaderReader(raf);
        final ZipModel zm = hr.readAllHeaders();
        final CentralDirectory centralDirectory = zm.getCentralDirectory();
        @SuppressWarnings("unchecked")
        final List<FileHeader> fhs = Collections.checkedList(centralDirectory.getFileHeaders(),
                FileHeader.class);

        final List<File> files = fhs.stream().map(fh -> {
            final File file = FileUtils.getFile(fileOut.getPath(), File.separator, fh.getFileName());
            unzippedContentsSize.add(file.length());
            return file;
        }).collect(Collectors.toList());

        if (!configuration.getFlag(KEEP_ZIPPED_FLAG))
            // Traverse directory and look for files to decompress
            for (final File file : files) {
                File decompressedFile = null;
                if (!file.isDirectory())
                    decompressedFile = archiveFile(file, false);

                if (decompressedFile != null) {
                    unzippedContentsSize.add(-FileUtils.sizeOf(file));
                    unzippedContentsSize.add(FileUtils.sizeOf(decompressedFile));
                    file.delete();
                }
            }

        raf.close();

        if (configuration.getFlag(DELETE_FLAG))
            if (!FileUtils.deleteQuietly(fileIn))
                System.err.printf(FILE_COULD_NOT_BE_DELETED_WARNING_FORMAT, fileIn.getPath());

        final double overallTime = (System.currentTimeMillis() - t0) / 1000d;

        if (configuration.getFlag(VERBOSE_FLAG)) {
            // Get the percent deflation on the compressed file
            final double percDeflated = 100 * unzippedContentsSize.doubleValue() / inputFileSize;

            System.out.printf(VERBOSE_DECOMPRESSION_INFO_FORMAT, fileIn.getName(), overallTime, percDeflated);
        }
    } catch (final Exception e) {
        e.printStackTrace();
    }

    return fileOut;
}

From source file:org.apache.sysml.runtime.instructions.gpu.context.GPUMemoryManager.java

/**
 * Convenient method to add misc timers// www  .  j  a v a  2s. c om
 * 
 * @param opcode opcode
 * @param globalGPUTimer member of GPUStatistics
 * @param globalGPUCounter member of GPUStatistics
 * @param instructionLevelTimer member of GPUInstruction
 * @param startTime start time
 */
private void addMiscTime(String opcode, LongAdder globalGPUTimer, LongAdder globalGPUCounter,
        String instructionLevelTimer, long startTime) {
    if (DMLScript.STATISTICS) {
        long totalTime = System.nanoTime() - startTime;
        globalGPUTimer.add(totalTime);
        globalGPUCounter.add(1);
        if (opcode != null && DMLScript.FINEGRAINED_STATISTICS)
            GPUStatistics.maintainCPMiscTimes(opcode, instructionLevelTimer, totalTime);
    }
}