help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Lexical binding doesn't seem to be faster?


From: Hi-Angel
Subject: Lexical binding doesn't seem to be faster?
Date: Thu, 7 Mar 2019 02:36:39 +0300

I've stumbled upon a discussion about converting Emacs code to a
faster lexical-binding and that help needed. I noted that cc-mode.el
I'm regularly use doesn't have one, and figured I could help.

So I inserted to cc-mode.el in emacs-git revision I have:

    ;;; -*- lexical-binding: t -*-

The first bad sign happened to be sizes of cc-mode.elc:

    ;;; -*- lexical-binding: t -*-   | 217581
    ;;; -*- lexical-binding: nil -*- | 212542

Lexical-binding bloats byte-code by 5KB. Odd. I tried comparing
assembly, but without experience in reading lisp assembly I haven't
come up with anything. So I thought "Okay, must be heavy inlining;
let's just compare the speed".

So, I took someone's function `with-timer` for benchmarking┬╣; and then
for both t and nil lexical-binding I did following steps:

1. `byte-compile` `cc-mode.el`
2. `load-file`    `cc-mode.elc`
3. open a 5k lines C file┬▓
4. Execute multiple times `(with-timer (c-font-lock-fontify-region 0
(point-max)))`
5. Kill the buffer.

These are results I got:

    ;;; -*- lexical-binding: t -*-   | 1.174s, 1.144s, 1.177s, 1.125s, 1.177s
    ;;; -*- lexical-binding: nil -*- | 1.037s, 1.061s, 1.037s, 1.037s, 0.991s


1: 
https://emacs.stackexchange.com/a/541/2671#how-do-i-measure-performance-of-elisp-code
2: 
https://gitlab.freedesktop.org/libinput/libinput/blob/9a2d6f55b1276da11dd9b2c4c8e22a405576dfea/src/libinput.h



reply via email to

[Prev in Thread] Current Thread [Next in Thread]