74 lines
No EOL
2.8 KiB
C#
74 lines
No EOL
2.8 KiB
C#
using System;
|
|
using System.Linq;
|
|
using JD.LogService;
|
|
using JD.Timeline.View.Actions.Refactor;
|
|
using TeaBox;
|
|
using TeaBox.Macros;
|
|
|
|
namespace JD.Timeline.View.Actions.Macros
|
|
{
|
|
[Module]
|
|
public class Statistics : TapeActionHandlerBase
|
|
{
|
|
[Macro]
|
|
public void ClipCount(IExecutionContext context)
|
|
{
|
|
context.LogMessage(MessageImportance.High, $"There are {CurrentTape.Clips.Count} clips");
|
|
foreach (var group in CurrentTape.Clips.GroupBy(clip => clip.Type))
|
|
{
|
|
context.LogMessage(MessageImportance.High, string.Format(" {1} => {0} clips", group.Count(), group.Key));
|
|
}
|
|
}
|
|
|
|
[Macro]
|
|
public void MaxSimultanousPlayed(IExecutionContext context)
|
|
{
|
|
int lastFrame = CurrentTape.Clips.Select(clip => clip.StopFrame).Max();
|
|
|
|
int totalClips = 0;
|
|
int maximumClipInFrame = 0;
|
|
int maximumFrame = 0;
|
|
for (int frame = 0; frame <= lastFrame; frame++)
|
|
{
|
|
int clipsForFrame = CurrentTape.Clips.Where(clip => clip.StartFrame <= frame && frame <= clip.StopFrame).Count();
|
|
if (clipsForFrame > maximumClipInFrame)
|
|
{
|
|
maximumClipInFrame = clipsForFrame;
|
|
maximumFrame = frame;
|
|
}
|
|
totalClips += clipsForFrame;
|
|
}
|
|
|
|
context.LogMessage(MessageImportance.High,
|
|
$"At most, there are {maximumClipInFrame} clips being played simulatenously (frame {maximumFrame}). On average there are {(float) totalClips / (float) lastFrame} clips played per frame");
|
|
}
|
|
|
|
#region Global Data Analysis
|
|
|
|
[Macro(ThreadAffinity.ExecuteAsync)]
|
|
public void GlobalUsageOfTML(IExecutionContext context, int maxFileCount, bool useCache)
|
|
{
|
|
new TapeStatistics().AnalyzeDataFolder(context, maxFileCount, TapeStatistics.ReportType.TimelineEditor, useCache);
|
|
}
|
|
|
|
[Macro(ThreadAffinity.ExecuteAsync)]
|
|
public void GlobalUsageOfTrec(IExecutionContext context, int maxFileCount, bool useCache)
|
|
{
|
|
new TapeStatistics().AnalyzeDataFolder(context, maxFileCount, TapeStatistics.ReportType.Tapes, useCache);
|
|
}
|
|
|
|
[Macro(ThreadAffinity.ExecuteAsync)]
|
|
public void GlobalUsageOfTrec_InMaps(IExecutionContext context, int maxFileCount, bool useCache)
|
|
{
|
|
new TapeStatistics().AnalyzeDataFolder(context, maxFileCount, TapeStatistics.ReportType.MapTapes, useCache);
|
|
}
|
|
|
|
[Macro(ThreadAffinity.ExecuteAsync)]
|
|
public void GlobalUsageOfTrec_InUI(IExecutionContext context, int maxFileCount, bool useCache)
|
|
{
|
|
new TapeStatistics().AnalyzeDataFolder(context, maxFileCount, TapeStatistics.ReportType.UITapes, useCache);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |