Skip to content

Instantly share code, notes, and snippets.

# なぜかわずかな違いで実行速度が倍違う
この記事では、`old Makefile` と `new Makefile` で生成されたバイナリの実行速度における200%の差について考察します。二つのMakefileにはわずかな違いしかないにも関わらず、最終的に生成される実行ファイルの性能が大きく異なる理由を探ることは、コンパイルオプションやビルドプロセスがパフォーマンスに与える影響について深く考える良い機会です。
## old Makefile の内容と問題点
まず、`old Makefile`を見てみましょう。
```makefile
CFLAGS=-O3 -march=native -mwindows -Wall -Wextra -Werror -flto -fno-exceptions
@sys9kdr
sys9kdr / os-detect-neovim-benchmarks.lua
Last active November 23, 2024 12:21
neovimのos特定の速度のベンチ
-- 測定回数
local iterations = 100000
-- ヘルパー関数で時間を計測
local function measure_time(fn)
local start = vim.uv.hrtime()
for _ = 1, iterations do
fn()
end
local duration = vim.uv.hrtime() - start

nvim-treesitterでどこに何がインストールされているか確認するためにこの辺りを見る。 TSUninsallでアンインストールされないときとかparserの位置を見てreviesionを捨てる。

  • nvim_get_runtime_file('queries/your_lang_name/*.scm', v:true)
  • lua vim.print(vim.api.nvim_get_runtime_file('parser', true))
@sys9kdr
sys9kdr / FindChangeByList.jsx
Created October 28, 2024 09:00 — forked from senki/FindChangeByList.jsx
Slightly modified `FindChangeByList.jsx` for InDesign CS6 - supports multiple List file
//FindChangeByList.jsx
//An InDesign CS6 JavaScript
/*
@@@BUILDINFO@@@ "FindChangeByList.jsx" 3.0.0 15 December 2009
Mod by senki on 2015-06-29
- added dialog with list of files under FindChangeSupport
- and choose between. default is the first
*/
//Loads a series of tab-delimited strings from a text file, then performs a series
//of find/change operations based on the strings read from the file.
#include <stdio.h>
#include <windows.h>
#define IME_CONTROL 0x283
#define IMC_GETOPENSTATUS 0x5
#define IMC_SETOPENSTATUS 0x6
int main(int argc, char** argv) {
HWND fg = GetForegroundWindow();

WSLで(WSLgで?)XDG_RUNTIME_DIRが変になる問題

WSL(でかつWSLgが有効)だとXDG_RUNTIME_DIRがWSLg用の1000で固定されるが、そのディレクトリがそもそも存在しないっぽい。

microsoft/WSL#9689

neovim/neovim#30282

microsoft/WSL#8918

-- 測定回数
local iterations = 100000
-- ヘルパー関数で時間を計測
local function measure_time(fn)
local start = vim.uv.hrtime()
for _ = 1, iterations do
fn()
end
local duration = vim.uv.hrtime() - start
@sys9kdr
sys9kdr / nvim_set_option_valueでsetlocalっぽい挙動にしたいとき.md
Last active April 29, 2024 01:46
nvim_set_option_valueでsetlocalするために必要なこと

nvimのheadで検証中(v0.10系)

nvim_set_option_valueでなんでもcurrent bufferにしようとしてもうまくいかない

neovim、setlocal相当のことをnvim_set_option_valueやりたいとき、 buffer localな設定ができるnvim_set_option_value(OPTION, VALUE, { buf = 0 })を使おうと考えることがあるかもしれない。

ただ、nvim_set_option_value(..., ..., { buf = 0 })setlocalな動作をするわけではない。 { buf = 0 }はbuffer localなセットをするだけで、例えば次のコードはエラーになる。

@sys9kdr
sys9kdr / japanese-annoyance-filter.abp.txt
Last active November 10, 2024 12:47
日本語向けのannoyanceフィルター
||mixi.net$third-party
||mixi.jp$third-party
||blogroll.livedoor.net^
||parts.blog.livedoor.jp^$script
||line-website.com/social-plugins^