org.github.jamm.MemoryMeter Java Examples

The following examples show how to use org.github.jamm.MemoryMeter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleNBodySimulationCS257.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
private boolean check_exit(int steps, SimpleNBodyCS257 simulation) {
	if (t >= steps) {
		loopZeroTime = simulation.getLoopZeroTime();
		loopOneTime = simulation.getLoopOneTime();
		loopTwoTime = simulation.getLoopTwoTime();
		loopThreeTime = simulation.getLoopThreeTime();
		totalTime = simulation.getTotalTime();
		// 20 floating point operations
		// 14 to calculate acceleration
		// 6 for velocity and position
		flops = ((14.0*N*N + 6.0*N) * steps)/ 1.0e9 / simulation.getTotalTime();
		// 10 Arrays of size 10;
		MemoryMeter meter = new MemoryMeter();
	    long s = meter.measure(new double[N]);
		bytes = (s * 10.0f * steps) / 1000000.0f / simulation.getTotalTime();
		// Verify solution.
		verify();			
		return true;
	}
	return false;
}
 
Example #2
Source File: AxisAlignedCuboid.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Collection<NBody3DBody> stepSimulation(Collection<NBody3DBody> universe) {
	List<NBody3DBody> qb = new ArrayList<NBody3DBody>();
	universe.stream().filter(b -> b.insideCube(this)).forEach(b -> qb.add(b));
	NBody3DBody[] quadrantBodies = qb.toArray(new NBody3DBody[qb.size()]);
	MemoryMeter meter = new MemoryMeter();
	memSize = meter.measure(universe);
	memSize += meter.measure(quadrantBodies);
	memSize += meter.measure(this);
	size = qb.size();
	long loop = System.nanoTime();
	prepare(quadrantBodies);
	durations = durations.logPrepare(loop);
	loop = System.nanoTime();
	accelerate(quadrantBodies, universe);
	durations = durations.logAccel(loop);
	loop = System.nanoTime();
	updateVelocity(quadrantBodies);
	durations = durations.logVel(loop);
	loop = System.nanoTime();
	updatePositions(quadrantBodies);
	durations = durations.logPos(loop);
	return Arrays.asList(quadrantBodies);	
}
 
Example #3
Source File: MemoryBenchmark.java    From caffeine with Apache License 2.0 6 votes vote down vote up
public void run() throws Exception {
  if (!MemoryMeter.hasInstrumentation()) {
    out.println("WARNING: Java agent not installed - guessing instead");
  }
  out.println();
  unbounded();
  maximumSize();
  maximumSize_expireAfterAccess();
  maximumSize_expireAfterWrite();
  maximumSize_refreshAfterWrite();
  maximumWeight();
  expireAfterAccess();
  expireAfterWrite();
  expireAfterAccess_expireAfterWrite();
  weakKeys();
  weakValues();
  weakKeys_weakValues();
  weakKeys_softValues();
  softValues();
}
 
Example #4
Source File: KhanSessionManager.java    From khan-session with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * HttpSession 객체에 대한 메모리 점유 사이즈를 계산
 *
 * @param session
 * @return
 */
private long getSessionMemorySize(HttpSession session) {
    if( statsEnabled == false )
        return 0;
    else if( khanSessionConfig.isEnableMemoryStatistics() == false )
        return 0;

    if( memoryStatError )
        return 0;

    // TODO : agent를 설정하지 않을 경우를 체크해야 함
    long memorySize = 0;
    try {
        MemoryMeter meter = new MemoryMeter();
        memorySize += meter.measureDeep(getSessionAttributes(session.getId()));
    } catch (Exception e) {
        log.error("Session memory size calculation error");
        memoryStatError = true;
    }
    return memorySize;
}
 
Example #5
Source File: IngraphDriver.java    From trainbenchmark with Eclipse Public License 1.0 5 votes vote down vote up
public void maybeMeasureMemory() throws IOException {
	final String memPath = bc.getMemoryMeasurementPath();
	if (memPath != null) {
		final MemoryMeter meter = new MemoryMeter();
		final long memoryB = meter.measureDeep(adapter.engine());
		final double memoryMB = memoryB / Math.pow(10, 6);
		final String line = String.join(",",
				Arrays.asList(bc.getToolName(), bc.getQueryVariant(), bc.getFileName(), String.format("%.02f", memoryMB))) + "\n";

		FileUtils.write(new File(memPath), line, Charset.defaultCharset(), true);
	}
}
 
Example #6
Source File: IndexMemtable.java    From sasi with Apache License 2.0 5 votes vote down vote up
public IndexMemtable(final SSTableAttachedSecondaryIndex backend)
{
    this.indexes = new NonBlockingHashMap<>();
    this.backend = backend;
    this.meter = new MemoryMeter().omitSharedBufferOverhead().withTrackerProvider(new Callable<Set<Object>>()
    {
        public Set<Object> call() throws Exception
        {
            // avoid counting this once for each row
            Set<Object> set = Collections.newSetFromMap(new IdentityHashMap<Object, Boolean>());
            set.add(backend.getBaseCfs().metadata);
            return set;
        }
    });
}
 
Example #7
Source File: WeightedSort.java    From bidder with Apache License 2.0 4 votes vote down vote up
public static void main(String [] args) throws Exception {

        MemoryMeter meter = new MemoryMeter();

        double time = System.nanoTime();
        List<Weighted> x = new ArrayList<Weighted>();
        x.add(new Thing("Large",100));
        x.add(new Thing("XLarge",1000));
        x.add(new Thing("Small",75));
        for (int i=0;i<100;i++) {
            x.add(new Thing("X" + i, i+0));
        }

        x.add(new Thing("SuperLarge", 11000));

        System.out.print("TIME=" + time/1000 );
        System.out.println();

        for (int i=0;i<100;i++) {
            time = System.nanoTime();
            Thing z = (Thing)weightedPickHeavy(x);
            time = System.nanoTime() - time;
            System.out.print("" + time/1000 + " = ");
            System.out.print(z.name + " ");
            System.out.println();
        }

        System.out.println("OBJECT SIZE: " + meter.measureDeep(x));

        System.out.println("-------------------------");


        ProportionalRandomCollection prc = new ProportionalRandomCollection("testing");

        double now = System.currentTimeMillis();
        for (int z=0;z<1000000;z++) {
            prc.addEntry("line"+z, "Large", 100);
            prc.addEntry("XLarger", 1000);
            prc.addEntry("Small", 75);
            for (int i = 1; i < 101; i++) {
                prc.addEntry("X" + i, i);
            }
        }
        now = System.currentTimeMillis() - now;
        now /= 60000;
        System.out.println("Setup: " + now);

        double total = 0;
        String s = null;
        for (int i=0;i<1000;i++) {
            time = System.nanoTime();
            s = prc.next("line1");
            time = System.nanoTime() - time;
            time /= 1000;
            total += time;
        }
        System.out.println("LOOKUP: '" + s + "' in " + total/1000);

        System.out.println("OBJECT SIZE: " + meter.measureDeep(prc));

    }
 
Example #8
Source File: SkipListMemIndex.java    From sasi with Apache License 2.0 4 votes vote down vote up
@Override
public long estimateSize(MemoryMeter meter)
{
    return meter.measureDeep(index);
}
 
Example #9
Source File: TrieMemIndex.java    From sasi with Apache License 2.0 4 votes vote down vote up
@Override
public long estimateSize(MemoryMeter meter)
{
    return meter.measureDeep(index);
}
 
Example #10
Source File: MemIndex.java    From sasi with Apache License 2.0 votes vote down vote up
public abstract long estimateSize(MemoryMeter meter);