本文整理汇总了Python中ufora.native.FORA.splitPausedComputation方法的典型用法代码示例。如果您正苦于以下问题:Python FORA.splitPausedComputation方法的具体用法?Python FORA.splitPausedComputation怎么用?Python FORA.splitPausedComputation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ufora.native.FORA
的用法示例。
在下文中一共展示了FORA.splitPausedComputation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: randomSplitComputationTest
# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import splitPausedComputation [as 别名]
def randomSplitComputationTest(self, text):
if (isinstance(text, str)):
funImplVal = FORA.extractImplValContainer(FORA.eval(text))
else:
funImplVal = text
unsplitVal = callAndGetResult(funImplVal)
splitAtLeastOne = False
i = 0
while (i < 3000):
i += 1
try:
pausedComputation = callAndExtractPausedCompuationAfterSteps(funImplVal, i)
except NotInterruptedException as e:
break
splitComputation = ForaNative.splitPausedComputation(pausedComputation)
unsplitVal2 = finishPausedComputation(pausedComputation)
self.assertEqual(unsplitVal, unsplitVal2)
if (splitComputation):
splitAtLeastOne = True
applyComputationVal = finishPausedComputation(splitComputation.applyComputation)
splitComputationVal = finishPausedComputation(splitComputation.splitComputation)
resumedComputation = ForaNative.joinSplitPausedComputation(
splitComputation,
applyComputationVal,
splitComputationVal
)
finalSplitVal = finishPausedComputation(resumedComputation)
self.assertEqual(unsplitVal, finalSplitVal)
if (not splitAtLeastOne):
logging.warn("didn't split any versions of `%s`\nafter i = %s tries" % (text, i))
示例2: test_cannotSplitThingsWithMutables
# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import splitPausedComputation [as 别名]
def test_cannotSplitThingsWithMutables(self):
text = """fun() {
let s = fun(a,b,f) {
if (b <= a)
return nothing
if (b <= a + 1)
return f(a)
let mid = Int64((a+b)/2)
return s(a,mid,f) + s(mid,b,f)
}
let m = MutableVector.create(10,10);
s(0,1000,fun(x){m[0] * x})
}"""
funImplval = FORA.extractImplValContainer(FORA.eval(text))
i = 0
while (i < 30000):
i += 1000
try:
pausedComputation = callAndExtractPausedCompuationAfterSteps(funImplval, i)
except NotInterruptedException as e:
break
allAreCST = True
for val in pausedComputation.frames[0].values:
if not val.isCST():
allAreCST = False
break
if not allAreCST:
splitComputation = ForaNative.splitPausedComputation(pausedComputation)
self.assertTrue(not splitComputation, splitComputation)
示例3: test_splitComputation_2
# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import splitPausedComputation [as 别名]
def test_splitComputation_2(self):
text = """fun() {
let s = fun(a,b,f) {
if (b <= a)
return nothing
if (b <= a + 1)
return f(a)
let mid = Int64((a+b)/2)
return s(a,mid,f) + s(mid,b,f)
}
s(0,1000,fun(x){x})
}"""
funImplval = FORA.extractImplValContainer(FORA.eval(text))
pausedComputation = callAndExtractPausedCompuationAfterSteps(funImplval, 35)
splitComputation = ForaNative.splitPausedComputation(pausedComputation)
self.assertIsNotNone(splitComputation)
unsplitValue = finishPausedComputation(pausedComputation)
applyComputationVal = finishPausedComputation(splitComputation.applyComputation)
splitComputationVal = finishPausedComputation(splitComputation.splitComputation)
resumedComputation = ForaNative.joinSplitPausedComputation(
splitComputation,
applyComputationVal,
splitComputationVal
)
finalSplitVal = finishPausedComputation(resumedComputation)
self.assertEqual(unsplitValue, finalSplitVal)
示例4: test_splitComputation_1
# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import splitPausedComputation [as 别名]
def test_splitComputation_1(self):
text = """fun() {
let s = fun(a,b,f) {
if (b <= a)
return nothing
if (b <= a + 1)
return f(a)
let mid = Int64((a+b)/2)
return s(a,mid,f) + s(mid,b,f)
}
let m = [0];
s(0,1000,fun(x){m[0] * x})
}"""
funImplval = FORA.extractImplValContainer(FORA.eval(text))
# minimum value to split seems to be 40
pausedComputation = callAndExtractPausedCompuationAfterSteps(funImplval, 40)
splitComputation = ForaNative.splitPausedComputation(pausedComputation)
self.assertTrue(splitComputation is not None)