Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不给糖就捣蛋
dr_py
提交
53628456
dr_py
项目概览
不给糖就捣蛋
/
dr_py
与 Fork 源项目一致
Fork自
晚风拂柳颜 / dr_py
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
dr_py
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
53628456
编写于
9月 27, 2022
作者:
H
hjdhnx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加性能对比和测试案例
上级
6662861e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
39 addition
and
1 deletion
+39
-1
js/version.txt
js/version.txt
+1
-1
py/qkjs/quick.py
py/qkjs/quick.py
+38
-0
未找到文件。
js/version.txt
浏览文件 @
53628456
3.7.16
\ No newline at end of file
3.7.17
\ No newline at end of file
py/qkjs/quick.py
浏览文件 @
53628456
from
quickjs
import
Function
,
Context
import
requests
from
time
import
time
import
js2py
import
json
ctx
=
Context
()
ctx
.
add_callable
(
"print"
,
print
)
...
...
@@ -85,4 +87,40 @@ def request(url):
ctx
.
add_callable
(
'request'
,
request
)
ctx
.
eval
(
'bd()'
)
t1
=
time
()
with
open
(
'../../js/兔小贝.js'
,
encoding
=
'utf-8'
)
as
f1
:
jscode
=
f1
.
read
()
print
(
jscode
)
ctx1
=
Context
()
ctx1
.
eval
(
jscode
)
ret
=
ctx1
.
get
(
'rule'
)
print
(
type
(
ret
.
json
()),
ret
.
json
())
print
(
json
.
loads
(
ret
.
json
()))
t2
=
time
()
print
(
f
'quickjs耗时:
{
round
((
t2
-
t1
)
*
1000
,
2
)
}
毫秒'
)
tt1
=
time
()
ctx1
.
eval
(
jscode
)
ret
=
ctx1
.
get
(
'rule'
)
print
(
type
(
ret
.
json
()),
ret
.
json
())
print
(
json
.
loads
(
ret
.
json
()))
tt2
=
time
()
print
(
f
'quickjs第2次耗时:
{
round
((
tt2
-
tt1
)
*
1000
,
2
)
}
毫秒'
)
t3
=
time
()
with
open
(
'../../js/兔小贝.js'
,
encoding
=
'utf-8'
)
as
f1
:
jscode
=
f1
.
read
()
print
(
jscode
)
ctx2
=
js2py
.
EvalJs
({},
enable_require
=
False
)
# enable_require启用require关键字,会自动获取系统nodejs环境
ctx2
.
execute
(
jscode
)
ret
=
ctx2
.
rule
.
to_dict
()
print
(
type
(
ret
),
ret
)
t4
=
time
()
print
(
f
'js2py耗时:
{
round
((
t4
-
t3
)
*
1000
,
2
)
}
毫秒'
)
t5
=
time
()
ctx2
.
execute
(
jscode
)
ret
=
ctx2
.
rule
.
to_dict
()
print
(
type
(
ret
),
ret
)
t6
=
time
()
print
(
f
'js2py第2次耗时:
{
round
((
t6
-
t5
)
*
1000
,
2
)
}
毫秒'
)
# 报错提示:(没法把python对象给qkjs,基础数据类型字典也不行,json等包更不行了) Unsupported type when converting a Python object to quickjs: dict.
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录