簡易檢索 / 詳目顯示

研究生: 陳怡靜
Chen, Yi-Ching
論文名稱: Emacs Lisp 多維陣列實作的效能比較
A Performance Comparison of Multidimensional Array Implementations of Emacs Lisp
指導教授: 賀保羅
Paul Horton
學位類別: 碩士
Master
系所名稱: 電機資訊學院 - 資訊工程學系
Department of Computer Science and Information Engineering
論文出版年: 2023
畢業學年度: 111
語文別: 英文
論文頁數: 54
中文關鍵詞: 多維陣列Emacs Lisp跨語言函式介面
外文關鍵詞: Multidimensional Arrays, Emacs Lisp, Foreign Function Interface
相關次數: 點閱:136下載:12
分享至:
查詢本校圖書館目錄 查詢臺灣博碩士論文知識加值系統 勘誤回報
  • Emacs 是一款歷史悠久且具有強大自訂性的多功能文字編輯器。然而,用以擴展 Emacs 功能的程式語言 Emacs Lisp 對於多維陣列並沒有語法上的支援,使得需要使用到多維陣列的場景用起來並不方便。本研究探討了在 Emacs Lisp 中增加多維陣列支援的方法,分別是 C 語言動態模組與 Emacs Lisp 自訂函式,並對兩者效能進行比較。過程中我們實作了 nested 及 flattened 兩種結構的多維陣列,並在實驗結果證明,在多數情境下,C 語言動態模組的實作在搭配這兩種結構的多維陣列時,表現皆優於已編譯和未編譯的 Emacs Lisp 自訂函式實作。然而,隨著規模增大,使用 C 語言動態模組的效能優勢便會逐步縮小,部分編譯過的 Emacs Lisp 自訂函式甚至能有更好的表現,這表示在 Emacs 環境中,C 語言動態模組的實作在操作大型陣列時可能會面臨挑戰。儘管我們的方法存在局限,但在大部分情況下仍有效提升 Emacs Lisp 處理多維陣列的效能。此外,我們的實作也提供了更直覺的多維陣列操作介面,有助於提高開發效率。這次的研究成果應將為 Emacs Lisp 在多維陣列處理方面提供實用的參考。

    Emacs is a venerable and highly customizable multi-purpose text editor. However, Emacs Lisp, the programming language used for extending Emacs, lacks syntactic support for multi-dimensional arrays, which can render tasks requiring such arrays inconvenient. This research explores the addition of multi-dimensional array support to Emacs Lisp through the utilization of C dynamic modules and custom Emacs Lisp functions. It compares their performance, implementing both nested and flattened structures for multi-dimensional arrays. Our experimental results indicate that, in the majority of scenarios, the C dynamic module implementation outperforms both compiled and interpreted custom Emacs Lisp function implementations when paired with these structures. Nonetheless, as the size of the multi-dimensional array increases, the performance advantage of the C dynamic modules gradually diminishes, and some compiled Emacs Lisp functions may even surpass it. This implies that using C dynamic modules for handling large arrays within the Emacs environment may encounter challenges. Despite these limitations, our methods enhance the performance of Emacs Lisp when dealing with multi-dimensional arrays. Moreover, our implementation provides a more intuitive interface for multi-dimensional array operations, contributing to increased development efficiency. As such, the findings of this study offer a practical reference for handling multi-dimensional arrays in Emacs Lisp.

    中文摘要 i Abstract iii 誌謝 v Contents vi List of Tables ix List of Figures xi 1 Introduction 1 1.1 Basic Knowledge of Emacs Lisp 1 1.2 Arrays in Emacs Lisp 3 1.3 C FFI in Emacs 4 1.4 Lack of Multi-Dim Arrays 6 2 Related Work 7 2.1 Multi-Dim Arrays in Other Languages 7 3 Methods 9 3.1 Custom Library 9 3.1.1 Nested Multi-dimensional Arrays 10 3.1.2 Flattened Multi-dimensional Arrays 12 3.2 Dynamically-Loaded Modules using C FFI 14 3.2.1 Development Process 14 3.2.2 Multi-Dimensional Array Design 15 3.2.3 Memory Management Issues 17 3.2.4 Demonstration of Creating and Using Multi-Dimensional Arrays 19 4 Results 21 4.1 Experimental Design 21 4.2 Execution Performance 22 4.2.1 Performance with Increasing Dimensions 22 4.2.2 Performance with Size Variations 25 4.2.3 Results from the Edit Distance Application 26 5 Discussion 30 5.1 Module and Library Performance 30 5.2 Nested vs. Flattened Arrays Performance 32 5.3 Bytecode Performance Analysis 34 5.4 Performance Comparison with SBCL 36 5.5 Future Work 36 6 Conclusion 39 Bibliography 40 A Array Performance Comparison 41 A.1 Array Comparison 41 B Shared Functionality 46 B.1 One-Dimensional Indexing 46 C Comparison of the make-array 49 C.1 Nested Version 49 C.2 Flattened Version 50 D Comparison of the ref-array 51 D.1 Nested Version 51 D.2 Flattened Version 52 E Comparison of the set-array 53 E.1 Nested Version 53 E.2 Flattened Version 54

    [1] Rocky Bernstein. GNU Emacs Lisp Bytecode Reference Manual. Accessed: 2023-06-30. 2018. URL: https://rocky.github.io/elisp-bytecode.pdf.
    [2] John Kitchin. Adding numerical methods to emacs with dynamic modules. Accessed:2023-03-01. 2017. URL: https://kitchingroup.cheme.cmu.edu/blog/2017/07/08/Adding-numerical-methods-to-emacs-with-dynamic-modules/.
    [3] Stefan Monnier and Michael Sperber. “Evolution of Emacs Lisp”. Proc. ACM Program.Lang. 4.HOPL (June 2020). DOI: 10.1145/3386324. URL: https://doi.org/10.1145/3386324.
    [4] José E. Moreira, Samuel P. Midkiff, and Manish Gupta. “A Comparison of Three Approaches to Language, Compiler, and Library Support for Multidimensional Arrays in Java”. Proceedings of the 2001 Joint ACM-ISCOPE Conference on Java Grande. JGI ’01. Palo Alto, California, USA: Association for Computing Machinery, 2001, pp. 116–125. ISBN: 1581133596. DOI: 10 . 1145 / 376656 . 376831. URL: https://doi.org/10.1145/376656.376831.
    [5] Multidimensional-array-dynamic-loading-module. [Source code]. GitHub. Available at: https://github.com/jj97181818/Multidimensional-array-dynamic-loading-module. 2023.
    [6] Writing Dynamically-Loaded Modules. https://www.gnu.org/software/emacs/manual/html_node/elisp/Writing-Dynamic-Modules.html. Accessed: 2023-03-01.

    下載圖示
    校外:立即公開
    QR CODE