;;; -*- lexical-binding:t -*- ;; Inspired by window--resize-child-windows-normal (defvar this-delta 10) (defvar window-height 50) (defvar window-normal-size 0.5) (defvar my-subs '(0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8)) (defvar my-tmp nil) ; (defun bench-nth (n l) ; (while (and l (not (zerop n))) ; (setq l (cdr l)) ; (setq n (1- n))) ; (car l)) (defun bench-with (n) (let ((start (float-time (get-internal-run-time))) (i 0)) (while (< i n) (let* ((delta-normal (if (= (- this-delta) window-height) (- window-normal-size) (/ (float this-delta) window-height))) (parent-normal 0.0)) (dolist (sub my-subs) (setq parent-normal (+ parent-normal window-normal-size sub))) (dolist (sub my-subs) (let ((old-normal (+ sub window-normal-size))) (setq my-tmp (min 1.0 ; Don't get larger than 1. (max (- old-normal (* (/ old-normal parent-normal) delta-normal)) ;; Don't drop below 0. 0.0))))) (let ((sum 0)) (dolist (sub my-subs) (setq sum (+ sum window-normal-size sub)) (setq my-tmp (min 1.0 (max (- 1.0 sum) 0.0)))))) (setq i (1+ i))) (- (float-time (get-internal-run-time)) start))) (defun bench-without (n) (let ((start (float-time (get-internal-run-time))) (i 0)) (while (< i n) (setq i (1+ i))) (- (float-time (get-internal-run-time)) start))) (defun bench (n) (- (bench-with n) (bench-without n)))