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


Python FORA.encodeStringInSerializedObject方法代码示例

本文整理汇总了Python中ufora.native.FORA.encodeStringInSerializedObject方法的典型用法代码示例。如果您正苦于以下问题:Python FORA.encodeStringInSerializedObject方法的具体用法?Python FORA.encodeStringInSerializedObject怎么用?Python FORA.encodeStringInSerializedObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ufora.native.FORA的用法示例。


在下文中一共展示了FORA.encodeStringInSerializedObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: diskThroughputTest

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import encodeStringInSerializedObject [as 别名]
    def diskThroughputTest(self, gb):
        if os.getenv("CUMULUS_DATA_DIR") is None:
            dataDir = tempfile.mkdtemp()
        else:
            dataDir = os.getenv("CUMULUS_DATA_DIR")
        dataDir = os.path.join(dataDir, str(uuid.uuid4()))

        diskCache = CumulusNative.DiskOfflineCache(
            callbackScheduler,
            dataDir,
            100 * 1024 * 1024 * 1024,
            100000
            )

        fiftyMegabytes = ForaNative.encodeStringInSerializedObject(" " * 1024 * 1024 * 50)

        logging.info("Writing to %s", dataDir)

        try:
            t0 = time.time()
            for ix in range(gb * 20):
                diskCache.store(
                    ForaNative.PageId(HashNative.Hash.sha1(str(ix)), 50 * 1024 * 1024, 50 * 1024 * 1024),
                    fiftyMegabytes
                    )

            PerformanceTestReporter.recordTest(
                "python.BigBox.Disk.Write%sGB" % gb,
                time.time() - t0,
                None
                )

            t0 = time.time()
            for ix in range(gb * 20):
                diskCache.loadIfExists(
                    ForaNative.PageId(HashNative.Hash.sha1(str(ix)), 50 * 1024 * 1024, 50 * 1024 * 1024)
                    )


            PerformanceTestReporter.recordTest(
                "python.BigBox.Disk.Read%sGB" % gb,
                time.time() - t0,
                None
                )

        finally:
            shutil.rmtree(dataDir)
开发者ID:Sandy4321,项目名称:ufora,代码行数:49,代码来源:testBigboxDiskPerf.py

示例2: test_disk_read_and_write_perf

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import encodeStringInSerializedObject [as 别名]
    def test_disk_read_and_write_perf(self):
        if os.getenv("CUMULUS_DATA_DIR") is None:
            dataDir = tempfile.mkdtemp()
        else:
            dataDir = os.getenv("CUMULUS_DATA_DIR")
        dataDir = os.path.join(dataDir, str(uuid.uuid4()))

        diskCache = CumulusNative.DiskOfflineCache(
            callbackScheduler,
            dataDir,
            100 * 1024 * 1024 * 1024,
            100000
            )

        try:
            fiftyMegabytes = ForaNative.encodeStringInSerializedObject(" " * 1024 * 1024 * 50)

            logging.info("Writing to %s", dataDir)

            storedPageID = ForaNative.PageId(HashNative.Hash.sha1("pageId"), 50 * 1024 * 1024, 50 * 1024 * 1024)

            diskCache.store(storedPageID, fiftyMegabytes)

            t0 = time.time()

            TOTAL_SECONDS = 20.0

            totalReadBytes = [0]
            totalWriteBytes = [0]

            def readerThread():
                while time.time() - t0 < TOTAL_SECONDS:
                    diskCache.loadIfExists(storedPageID)
                    totalReadBytes[0] += 50

            def writerThread():
                ix = 0
                while time.time() - t0 < TOTAL_SECONDS:
                    ix += 1
                    diskCache.store(
                        ForaNative.PageId(HashNative.Hash.sha1(str(ix)), 50 * 1024 * 1024, 50 * 1024 * 1024),
                        fiftyMegabytes
                        )
                    totalWriteBytes[0] += 50

            threads = [
                threading.Thread(target = readerThread),
                threading.Thread(target = writerThread)
                ]

            for t in threads:
                t.start()
            for t in threads:
                t.join()

            PerformanceTestReporter.recordTest(
                "python.BigBox.Disk.ReadAndWrite.Write1GB",
                1024 / (totalWriteBytes[0] / (time.time() - t0)),
                None
                )

            PerformanceTestReporter.recordTest(
                "python.BigBox.Disk.ReadAndWrite.Read1GB",
                1024 / (totalReadBytes[0] / (time.time() - t0)),
                None
                )

        finally:
            shutil.rmtree(dataDir)
开发者ID:Sandy4321,项目名称:ufora,代码行数:71,代码来源:testBigboxDiskPerf.py


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