当前位置: 首页 > 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.rkmt.cn/news/47237.html

相关文章:

  • AI元人文:价值原语化——构建从个体到文明的协同元代码
  • 2025年11月离婚房产律师推荐榜:许阿赛马赛男领衔五强对比评测
  • 2025年激光焊翅片管供应商权威推荐榜单:翅片管加热器/钢管轧铝翅片管/空气散热器供应商精选
  • VonaJS: 直观好用的分布式锁
  • 实用指南:计算机视觉(opencv)——实时颜色检测
  • 2025 年 11 月凝壳炉厂家推荐排行榜,真空感应凝壳炉,真空自耗凝壳炉,150kg真空凝壳炉,160kg真空凝壳炉,250kg真空凝壳炉,1t真空凝壳炉公司推荐
  • i am coming
  • 企业安全-互联网暴露面风险收敛
  • 信息论基础 | 第五章 编码理论
  • 2025 年 11 月桥架厂家推荐排行榜,电缆桥架,梯级式桥架,快速连接桥架,托盘式桥架,不锈钢桥架,深联桥架公司推荐
  • 十类图片深度学习提升准确率(0.9317) - 实践
  • conda相关命令
  • 2025网站建设公司口碑排行榜
  • [JQuery] inject jQuery into any webpage
  • 必看!上下文工程在智能家居的10个关键知识点,架构师整理 - 教程
  • tomcat/idea打包部署报错,RUN 可以 DEBUG 不行
  • 在CMake中打印所有变量
  • .NET 10发布和它的新增功能
  • 2025年EGUOO关节灵活营养素:深度解析七重配方科研链与临床实证
  • 2025年EGUOO关节灵活营养素:深度解析七重配方与专利矩阵
  • 详细介绍:Tomcat核心组件全解析
  • 2025年EGUOO调理肠胃健壮身体粉深度解析:科研壁垒与四重功效全盘点
  • 系统流量突然增加了10倍,该怎么办?
  • 接口(接口中的所有定义都是抽象的,都需要实现类)
  • Local Persistent Volume
  • Plan-and-Execute Agents
  • 无问智推:开启数据消费新范式
  • revit esc取消报错处理
  • 2025年定制全屋家居公司权威推荐榜单:全屋定制装修/全屋定制品牌/全屋定制源头公司精选
  • MATLAB实现图像去模糊