当前位置: 首页>>代码示例>>Java>>正文


Java AffinitySupport类代码示例

本文整理汇总了Java中net.openhft.affinity.AffinitySupport的典型用法代码示例。如果您正苦于以下问题:Java AffinitySupport类的具体用法?Java AffinitySupport怎么用?Java AffinitySupport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AffinitySupport类属于net.openhft.affinity包,在下文中一共展示了AffinitySupport类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGettid

import net.openhft.affinity.AffinitySupport; //导入依赖的package包/类
@Test
public void testGettid() {
    System.out.println("pid=" + getImpl().getProcessId());
    System.out.println("tid=" + getImpl().getThreadId());
    AffinitySupport.setThreadId();

    for (int j = 0; j < 3; j++) {
        final int runs = 100000;
        long tid = 0;
        long time = 0;
        for (int i = 0; i < runs; i++) {
            long start = System.nanoTime();
            tid = Thread.currentThread().getId();
            time += System.nanoTime() - start;
            assertTrue(tid > 0);
            assertTrue(tid < 1 << 16);
        }
        System.out.printf("gettid took an average of %,d ns, tid=%d%n", time / runs, tid);
    }
}
 
开发者ID:OpenHFT,项目名称:Java-Thread-Affinity,代码行数:21,代码来源:PosixJNAAffinityTest.java

示例2: setAffinity

import net.openhft.affinity.AffinitySupport; //导入依赖的package包/类
private static void setAffinity(final int cpuAffinity)
{
    if(cpuAffinity != Config.NO_AFFINITY)
    {
        System.out.println("Setting journaller thread affinity to cpu: " + cpuAffinity);
        final long cpuListBitMask = cpuListToBitMask(new int[]{cpuAffinity});
        AffinitySupport.setAffinity(cpuListBitMask);
    }
}
 
开发者ID:epickrram,项目名称:journalling-benchmark,代码行数:10,代码来源:TestMain.java

示例3: acquireCHM

import net.openhft.affinity.AffinitySupport; //导入依赖的package包/类
static ChronicleMap<String, BondVOInterface> acquireCHM() throws IOException {
    // ensure thread ids are globally unique.
    AffinitySupport.setThreadId();
    return ChronicleMapBuilder.of(String.class, BondVOInterface.class)
            .entries(16)
            .averageKeySize("369604101".length()).create();
}
 
开发者ID:OpenHFT,项目名称:Chronicle-Map,代码行数:8,代码来源:PingPongCASLeft.java

示例4: populate

import net.openhft.affinity.AffinitySupport; //导入依赖的package包/类
public static void populate(int n) {
    AffinitySupport.setThreadId();

    long start = System.currentTimeMillis();
    BigDataStuff value = new BigDataStuff(0);
    for (long i = n; i < MAXSIZE; i += 4) {
        if (n == 0 && i % (10 * 1000 * 1000) == 0) {
            System.out.println("Now inserted to " + i + " seconds since start = " + ((System.currentTimeMillis() - start) / 1000L));
        }
        value.x = i;
        value.y.setLength(0);
        value.y.append(i);
        theMap.put(i, value);
    }
}
 
开发者ID:OpenHFT,项目名称:Chronicle-Map,代码行数:16,代码来源:BigData.java

示例5: _test

import net.openhft.affinity.AffinitySupport; //导入依赖的package包/类
public static void _test() {
    // improves logging of these threads.
    AffinitySupport.setThreadId();
    try {
        test();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
 
开发者ID:OpenHFT,项目名称:Chronicle-Map,代码行数:11,代码来源:BigData.java


注:本文中的net.openhft.affinity.AffinitySupport类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。