Table of Contents

Property Duration

Namespace
LMKit.Agents
Assembly
LM-Kit.NET.dll

Duration

Gets the total execution duration.

public TimeSpan Duration { get; }

Property Value

TimeSpan

Examples

Measuring execution performance:

using LMKit.Model;
using LMKit.Agents;

using var model = new LM("path/to/model.gguf");
var agent = new Agent(model);

var result = agent.Run("Summarize the key points of machine learning.");

Console.WriteLine($"Response: {result.Content}");
Console.WriteLine($"Duration: {result.Duration.TotalSeconds:F2} seconds");
Console.WriteLine($"Inference calls: {result.InferenceCount}");

// Calculate average time per inference
if (result.InferenceCount > 0)
{
    var avgMs = result.Duration.TotalMilliseconds / result.InferenceCount;
    Console.WriteLine($"Avg per inference: {avgMs:F0}ms");
}

Remarks

Includes all time spent on inference, tool calls, and any internal processing. Useful for performance monitoring and optimization.