当前位置: 首页 > news >正文

Pyodide 环境

Pyodide 环境中正常运行了。从日志可以看到:

测试结果分析

环境信息:

  • ✅ Python 3.10.2
  • ✅ Pyodide 0.22.1
  • ✅ WebAssembly (Emscripten) 环境
  • ✅ 所有测试都成功完成

性能数据:

  • CPU性能:素数计算 0.022秒,浮点运算 0.764秒
  • 内存性能:列表和字典操作正常
  • 文件I/O:读写操作成功
  • 字符串操作:处理正常

查看完整日志文件的方法

由于日志文件已经创建成功,你可以用以下几种方式查看完整内容:

方法1:直接读取日志文件

# 查看完整的日志文件内容
def view_full_log():log_file = "pyodide_performance.log"if os.path.exists(log_file):print(f"=== 完整日志文件内容 ===")with open(log_file, 'r', encoding='utf-8') as f:content = f.read()print(content)print(f"文件大小: {len(content)} 字符")else:print("日志文件不存在")view_full_log()

方法2:分页查看

# 分页查看日志(每页20行)
def view_log_paginated():log_file = "pyodide_performance.log"if not os.path.exists(log_file):print("日志文件不存在")returnwith open(log_file, 'r', encoding='utf-8') as f:lines = f.readlines()page_size = 20total_pages = (len(lines) + page_size - 1) // page_sizefor page in range(total_pages):start = page * page_sizeend = start + page_sizeprint(f"\n=== 第 {page + 1}/{total_pages} 页 ===")for line in lines[start:end]:print(line.rstrip())if page < total_pages - 1:input("按回车继续...")  # 或者使用其他方式暂停# view_log_paginated()

方法3:关键信息提取

# 提取关键性能指标
def extract_performance_metrics():log_file = "pyodide_performance.log"if not os.path.exists(log_file):print("日志文件不存在")returnwith open(log_file, 'r', encoding='utf-8') as f:content = f.read()print("=== 关键性能指标 ===")# 提取CPU性能import recpu_patterns = {'素数计算': r'Prime calculation.*?: ([\d.]+) seconds','浮点运算': r'Float operations.*?: ([\d.]+) seconds','整数运算': r'Integer operations: ([\d.]+) seconds'}for name, pattern in cpu_patterns.items():match = re.search(pattern, content)if match:print(f"{name}: {match.group(1)} 秒")# 提取内存性能mem_pattern = r'List allocation.*?: ([\d.]+) seconds'match = re.search(mem_pattern, content)if match:print(f"内存分配: {match.group(1)} 秒")# 提取文件I/Oio_patterns = {'文件写入': r'File write.*?: ([\d.]+) seconds','文件读取': r'File read.*?: ([\d.]+) seconds'}for name, pattern in io_patterns.items():match = re.search(pattern, content)if match:print(f"{name}: {match.group(1)} 秒")extract_performance_metrics()

方法4:文件信息查看

# 查看文件详细信息
def show_file_info():log_file = "pyodide_performance.log"if os.path.exists(log_file):import datetimestat = os.stat(log_file)print("=== 日志文件信息 ===")print(f"文件名: {log_file}")print(f"完整路径: {os.path.abspath(log_file)}")print(f"文件大小: {stat.st_size} 字节")print(f"创建时间: {datetime.datetime.fromtimestamp(stat.st_ctime)}")print(f"修改时间: {datetime.datetime.fromtimestamp(stat.st_mtime)}")# 显示文件所在目录的其他文件print(f"\n当前目录文件列表:")for item in os.listdir('.'):if item.endswith('.log') or item.endswith('.txt'):size = os.path.getsize(item)print(f"  {item} ({size} bytes)")else:print("日志文件不存在")show_file_info()

运行建议

运行这个来查看完整日志:

view_full_log()
=== 完整日志文件内容 ===
PYODIDE PERFORMANCE TEST REPORT
==================================================
Test started: 2025-11-12 10:41:37.206000
Environment: Pyodide/WebAssembly
==================================================SYSTEM INFORMATION
----------------------------------------
Python version: 3.10.2 (main, Jan 25 2023, 18:32:53) [Clang 16.0.0 (https://github.com/llvm/llvm-project dee009d3b5c71a340eb4ebb3cfb4
Platform: emscripten
Current directory: /home/pyodide
Available modules: 729 loaded
Pyodide version: 0.22.1
----------------------------------------CPU PERFORMANCE TEST
----------------------------------------
Prime calculation (up to 10,000): 0.023 seconds
Primes found: 1229
Float operations (1M): 0.721 seconds
Result: 341.632263
Integer operations: 0.000 seconds
Factorial mod result: 0
----------------------------------------MEMORY PERFORMANCE TEST
----------------------------------------
List allocation (100K items): 0.022 seconds
Dict allocation (100K items): 0.029 seconds
List memory usage: 400492 bytes
Dict memory usage: 3145780 bytes
----------------------------------------STRING OPERATIONS TEST
----------------------------------------
String concatenation (10K): 0.003 seconds
String processing: 0.005 seconds
Uppercase letters: 2000
Lowercase letters: 8000
----------------------------------------FILE I/O PERFORMANCE TEST
----------------------------------------
File write (10K lines): 0.006 seconds
File read (10K lines): 0.003 seconds
Lines read: 10000
File size: 598890 bytes
----------------------------------------==================================================
TEST SUMMARY
==================================================
Total duration: 0.82 seconds
Tests completed: 5
Test finished: 2025-11-12 10:41:38.025000文件大小: 1759 字符

或者运行这个来查看关键指标:

extract_performance_metrics()
=== 关键性能指标 ===
素数计算: 0.023 秒
浮点运算: 0.721 秒
整数运算: 0.000 秒
内存分配: 0.022 秒
文件写入: 0.006 秒
文件读取: 0.003 秒

现在你有了一个完全兼容 Pyodide 环境的性能测试程序,可以正常创建和查看日志文件了!

http://www.jsqmd.com/news/38226/

相关文章:

  • 东方财富股票数据提取分析报告 - 2025年11月12日 - 10:49:33
  • 2025年高品质Z型斗式提升机厂家权威推荐榜单:耐用的Z型斗式提升机/正规的Z型斗式提升机/诚信的Z型斗式提升机源头厂家精选
  • 2025年EGUOO纳豆激酶功效:权威盘点心血管养护的科学边界与实证
  • NGINX Docker 镜像使用指南
  • Machine Learning - SVM
  • 2025年11月港股打新券商推荐:牌照合规性与服务实力综合评测排行榜
  • 智能呼叫中心系统测评推荐:从高并发处理到AI能力,深度剖析5大品牌的实战能力
  • 2025年EGUOO美国原装进口深度解析:本土研发到全球交付的全程品控链
  • 2025年EGUOO纳豆激酶:深度解析心血管膳食补充剂科研链路与市场真实表现
  • 2025年EGUOO纳豆激酶:深度解析心血管膳食补充剂的科研护城河
  • Skp版本转换器 支持 SketchUp3-2025(中文免费版)下载与安装教程
  • 常用设计模式:代理模式
  • 2025年山东直流电机维修公司权威推荐榜单:主轴电机维修/永磁电机维修/大型电机维修服务商精选
  • AI元人文:价值原语化——构建从个体到文明的协同元代码
  • 神经元为什么要设置偏置bias
  • 2025 年 11 月柏尔地板厂家推荐排行榜,定制地板,实木地板,高端定制,实木地热,实木双锁扣地板公司精选
  • 2025年11月离婚房产律师推荐榜:许阿赛马赛男领衔五强对比评测
  • 2025年激光焊翅片管供应商权威推荐榜单:翅片管加热器/钢管轧铝翅片管/空气散热器供应商精选
  • VonaJS: 直观好用的分布式锁
  • 实用指南:计算机视觉(opencv)——实时颜色检测
  • 2025 年 11 月悬浮炉厂家推荐排行榜,真空悬浮炉,真空感应悬浮炉,50kg悬浮炉,30kg悬浮炉,15kg悬浮炉,5kg悬浮炉公司精选
  • 2025 年 11 月凝壳炉厂家推荐排行榜,真空感应凝壳炉,真空自耗凝壳炉,150kg真空凝壳炉,160kg真空凝壳炉,250kg真空凝壳炉,1t真空凝壳炉公司推荐
  • i am coming
  • 企业安全-互联网暴露面风险收敛
  • 信息论基础 | 第五章 编码理论
  • 2025年高端员工工作服定做厂家权威推荐榜单:高端工服/高端劳保工作服/高端夏季工作服源头厂家精选
  • 2025 年 11 月桥架厂家推荐排行榜,电缆桥架,梯级式桥架,快速连接桥架,托盘式桥架,不锈钢桥架,深联桥架公司推荐
  • 在跳板机的远程桌面中输入ctrl+alt+end
  • 十类图片深度学习提升准确率(0.9317) - 实践
  • 2025年环氧防腐底漆生产厂家权威推荐榜单:水性有机硅/水性聚氨酯漆/双组份水性漆源头厂家精选