本文整理汇总了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)
示例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)