25 กุมภาพันธ์ 2560

Published กุมภาพันธ์ 25, 2560 by with 0 comment

วัดเปรียบเทียบประสิทธิภาพภาษา Python

คุณเคยสงสัยไหม หากคุณใช้ Python ไม่ว่าจะเป็น CPython เวชั่นเดิมหรือเวชั่นที่สั่ง build , PyPy และอื่น ๆ รวมถึงต่างสถาปัตยกรรมกัน คุณจะวัดเปรียบเทียบสมรรถนะภาษา Python บน Python implementations เหล่านี้ได้อย่างไร ?

ปัญหานี้แก้ไขได้ด้วย ชุดเครื่องมือวัดประสิทธิภาพในชื่อ "The Python Benchmark Suite"

[caption id="" align="alignnone" width="800"] รูปภาพที่สร้างจาก bm_raytrace (pure Python raytrace) ในชุดเครื่องมือ The Python Benchmark Suite[/caption]

ชุดเครื่องมือ "The Python Benchmark Suite" สามารถทำการทดสอบได้โดยต้องการ virtualenv

สำหรับ CPython สามารถติดตั้งได้ผ่านคำสั่ง $ pip install performance

สำหรับ Python implementations อื่น สามารถโหลดไฟล์มาติดตั้งได้จาก https://github.com/python/performance แตกไฟล์แล้วใช้คำสั่ง $ python setup.py install

การใช้งานเบื้องต้น
คำสั่งเปรียบเทียบ Python 2 กับ Python 3

pyperformance run --python=python2 -o py2.json
pyperformance run --python=python3 -o py3.json
pyperformance compare py2.json py3.json

อ่านเอกสารได้ที่ https://github.com/python/performance

0 ความคิดเห็น:

แสดงความคิดเห็น

แสดงความคิดเห็นได้ครับ :)