Performance hit from simple binding
Posted: 18 Jun 2019, 14:41
I have a DateTime that I'm updating every frame, and it's surprisingly taking a lot of cpu time.
Where it's updated:
Profiler:
https://i.imgur.com/oVSpgiY.png
https://i.imgur.com/T71v9KG.png
Sometimes it gets really bad:
https://i.imgur.com/YOBk5LC.png
I'm using a converter because I couldn't get the DateTime to display in a specific format without it (like how it works in WPF). I've also set many binded properties every frame before without any performance hits.
I'm on Unity 2019.1.5 / Noesis 2.2.3
EDIT: there seems to be a memory leak: https://i.imgur.com/yhfXiBe.png
Where it's updated:
Code: Select all
private void UpdateTime()
{
DeltaTime = TimeSpan.FromMinutes(Time.deltaTime * 4);
_game.Player.Time += DeltaTime;
}
Code: Select all
<TextBlock FontSize="30" Foreground="White" VerticalAlignment="Center" Margin="5"
Text="{Binding Game.Player.Time, Converter={StaticResource DateTimeFormat}, ConverterParameter=HH:mm}"/>
<Rectangle Width="1" Fill="White" Margin="5, 10"/>
<TextBlock FontSize="30" Foreground="White" VerticalAlignment="Center" Margin="5"
Text="{Binding Game.Player.Time.Day,StringFormat=Day: {0}}"/>
Code: Select all
public class DateTimeFormatConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return ((DateTime)value).ToString(parameter.ToString());
}
public object ConvertBack(object value, Type targetType, object parameter,
CultureInfo culture)
{
throw new NotImplementedException();
}
}
https://i.imgur.com/oVSpgiY.png
https://i.imgur.com/T71v9KG.png
Sometimes it gets really bad:
https://i.imgur.com/YOBk5LC.png
I'm using a converter because I couldn't get the DateTime to display in a specific format without it (like how it works in WPF). I've also set many binded properties every frame before without any performance hits.
I'm on Unity 2019.1.5 / Noesis 2.2.3
EDIT: there seems to be a memory leak: https://i.imgur.com/yhfXiBe.png