Skip to content

serve コマンドで処理時間を表示#49

Open
zztkm wants to merge 2 commits intomainfrom
feature/serve-build-time
Open

serve コマンドで処理時間を表示#49
zztkm wants to merge 2 commits intomainfrom
feature/serve-build-time

Conversation

@zztkm
Copy link
Member

@zztkm zztkm commented Feb 1, 2026

Summary

  • serve コマンドの初回ビルドと再ビルド(ファイル変更検知時)で処理時間を表示
  • build コマンドと同じフォーマット「build finished in {} ms」を使用

出力例

[INFO] Running initial build...
[INFO] Initial build completed
build finished in 123 ms
[INFO] serving on http://localhost:8080

[INFO] File changed, rebuilding...
[INFO] Rebuild completed
build finished in 45 ms

Test plan

  • cargo build でビルド成功を確認
  • cargo run -- serve を実行し、初回ビルドの処理時間が表示されることを確認
  • ソースファイルを変更し、再ビルドの処理時間が表示されることを確認

🤖 Generated with Claude Code

build コマンドと同じフォーマット「build finished in {} ms」で
処理時間を表示するようにした。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @zztkm, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

このプルリクエストは、serve コマンドのユーザーエクスペリエンスを向上させることを目的としています。具体的には、開発中にserveコマンドが実行するビルド処理(初回ビルドとファイル変更時の再ビルド)にかかる時間を表示することで、ユーザーはビルドのパフォーマンスを視覚的に把握できるようになります。これにより、開発者はビルド時間の最適化の必要性を判断したり、作業の進捗をより正確に理解したりすることが可能になります。

Highlights

  • ビルド時間の表示: serve コマンドにおいて、初回ビルド時およびファイル変更検知時の再ビルド時に処理時間を表示する機能を追加しました。
  • フォーマットの統一: 処理時間の表示フォーマットは、既存の build コマンドと同じ「build finished in {} ms」を使用しています。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

このプルリクエストは serve コマンドのビルド時に処理時間を表示する機能を追加するもので、変更内容は的確です。CHANGELOG.md の更新も適切に行われています。
コードの可読性と保守性をさらに向上させるために、ビルド時間計測のロジックが run_serve 関数と watch_files 関数で重複している点をリファクタリングすることを提案します。ヘルパー関数に処理をまとめることで、コードがよりクリーンになります。具体的な提案をコメントに記載しました。

Comment on lines 151 to 158
let start = std::time::Instant::now();
if let Err(e) = subcommand_build::run_build(&config_path_clone) {
eprintln!("[ERROR] Rebuild failed: {:#}", e);
} else {
let duration = start.elapsed();
println!("[INFO] Rebuild completed");
println!("build finished in {} ms", duration.as_millis());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

ビルド時間を計測するロジックが run_serve 関数(65-69行目)と watch_files 関数で重複しています。
このロジックをヘルパー関数に切り出すことで、コードの重複をなくし、保守性を向上させることができます。

例えば、以下のようなヘルパー関数を subcommand_serve.rs 内に定義します。

fn run_build_with_timing(config_path: &Path) -> Result<Duration> {
    let start = Instant::now();
    subcommand_build::run_build(config_path)?;
    Ok(start.elapsed())
}

このヘルパー関数を使うと、ここの処理は以下のように書き換えられます。
run_serve 関数内の同様の処理もこのヘルパー関数を使って書き換えることを推奨します。

加えて、Instant はファイルの先頭で use されているため、std::time::Instant のようにフルパスで指定する必要はありません。このリファクタリングで合わせて修正されます。

                    match run_build_with_timing(&config_path_clone) {
                        Ok(duration) => {
                            println!("[INFO] Rebuild completed");
                            println!("build finished in {} ms", duration.as_millis());
                        }
                        Err(e) => {
                            eprintln!("[ERROR] Rebuild failed: {:#}", e);
                        }
                    }

レビュー指摘対応:run_build_with_timing 関数を追加し、
初回ビルドと再ビルドで重複していたロジックを共通化した。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant