{"id":24956948,"url":"https://github.com/toyboot4e/lct-bench","last_synced_at":"2025-10-04T17:51:34.268Z","repository":{"id":274620288,"uuid":"923464835","full_name":"toyboot4e/lct-bench","owner":"toyboot4e","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-28T13:38:33.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T03:02:00.047Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/toyboot4e.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-28T09:46:40.000Z","updated_at":"2025-01-28T13:38:36.000Z","dependencies_parsed_at":"2025-01-28T12:31:05.474Z","dependency_job_id":"c68bebc9-31c8-4b78-88e7-55b5619ac566","html_url":"https://github.com/toyboot4e/lct-bench","commit_stats":null,"previous_names":["toyboot4e/lct-bench"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toyboot4e%2Flct-bench","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toyboot4e%2Flct-bench/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toyboot4e%2Flct-bench/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toyboot4e%2Flct-bench/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toyboot4e","download_url":"https://codeload.github.com/toyboot4e/lct-bench/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246100419,"owners_count":20723466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-03T06:41:44.067Z","updated_at":"2025-10-04T17:51:28.827Z","avatar_url":"https://github.com/toyboot4e.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"* LCT 高速化\n\n質問用のリポジトリです。\n\n*追記: 回答を頂いた結果、 =splay=, =rotate= に ={-# INLINABLE #-}= を付けると =0.678= 秒まで高速化されました。* 今までの体感としては ={-# INLINABLE #-}= には効果が無かったのですが、 private な関数には効くのかもしれません (裏取り無し) 。ありがとうございました！！\n\n** 質問内容\n\nC++ ライブラリを写経してテスト問題 ([[https://judge.yosupo.jp/problem/dynamic_tree_vertex_add_path_sum][Dynamic Tree Vertex Add Path Sum]]) を解きました。 C++ の実行結果 (0.259 秒) に比べ、 Haskell の実行結果 (2.47 秒) が約 10 倍遅いです。 C++ の 2 ~ 4 倍程度まで高速化したいのですが、何か方法に心当たりがあれば教えてください。\n\n- [[./hs/src/Lct.hs]]: link/cut tree の実装モジュールです。このソース中で高速化できる点があればお伺いしたいです。\n- [[./hs/app/lct-test.hs]]: テスト問題の回答プログラムです。\n\n=Lct.hs= は基本的に C++ 版の ([[./cpp/graph/ds/link_cut_tree.hpp]]) の写経です。データの持ち方が異なりますが、その他のソースはほぼ同一ですので、 Haskell ならではの低速化のポイントが無いか探しています。また追加で調べるべき情報などの指摘も頂けると幸いです。\n\n- CPP 版のデータの持ち方: =std::vector\u003cNode\u003e= (array of structs)\n- Haskell 版のデータの持ち方: =VU.Vector Int=, =VU.Vector Int=, =VU.Vector Int=, .. (struct of arrays)\n\n** 環境構築\n\nLinux の Nix (Flakes) ユーザは =direnv allow= で環境構築できると思います。\n\n他の環境はセットアップできておりません。ご了承ください。\n\n** テストの実行方法\n\n[[https://github.com/casey/just][=just=]] (タスクランナー) で実行します。\n\n*** C++ 版のテスト実行\n\n#+CAPTION: 実行コマンド\n#+BEGIN_SRC sh\n$ just cpp\n#+END_SRC\n\n#+CAPTION: 実行結果\n#+BEGIN_SRC txt\n[INFO] slowest: 0.259401 sec  (for max_random_02)\n[INFO] max memory: 17.440000 MB  (for max_random_00)\n[SUCCESS] test success: 12 cases\n#+END_SRC\n\n*** Haskell 版のテスト実行\n\n#+CAPTION: 実行コマンド\n#+BEGIN_SRC sh\n$ just hs\n#+END_SRC\n\n#+CAPTION: 実行結果\n#+BEGIN_SRC txt\n[INFO] slowest: 2.473940 sec  (for max_random_00)\n[INFO] max memory: 42.720000 MB  (for max_random_01)\n[SUCCESS] test success: 12 cases\nWARNING:onlinejudge_verify.languages.user_defined:The functionality to list dependencies of .hs file is not implemented yet.\n#+END_SRC\n\n#+BEGIN_QUOTE\nHaskell の入力処理は 0.109 秒でしたので、やはり LCT の計算部分が重いようです。\n#+END_QUOTE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoyboot4e%2Flct-bench","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoyboot4e%2Flct-bench","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoyboot4e%2Flct-bench/lists"}