Added benchmark classes for marshaling and reflection scenarios. (#33)

* Added benchmark classes for marshaling and reflection scenarios.

* Added benchmark scenarios
This commit is contained in:
ujjwalchadha 2020-07-22 15:22:05 -04:00 коммит произвёл GitHub
Родитель 479bfae3e3
Коммит e058f2fc16
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 199 добавлений и 0 удалений

Просмотреть файл

@ -1,6 +1,10 @@
#include "pch.h"
#include "BenchmarkComponent.h"
#include "ClassWithMultipleInterfaces.g.cpp"
#include "ClassWithMarshalingRoutines.g.cpp"
#include "WrappedClass.g.cpp"
using namespace winrt::Windows::Foundation;
namespace winrt::BenchmarkComponent::implementation
{
@ -61,4 +65,116 @@ namespace winrt::BenchmarkComponent::implementation
void ClassWithMultipleInterfaces::DefaultDoubleProperty(double val)
{
}
ClassWithMarshalingRoutines::ClassWithMarshalingRoutines()
{
keyValuePairObject = createKeyValuePairObject();
arrayObject = createArrayObject();
nullableObject = createNullableObject();
}
hstring ClassWithMarshalingRoutines::DefaultStringProperty()
{
return hstring();
}
void ClassWithMarshalingRoutines::DefaultStringProperty(hstring val)
{
}
Windows::Foundation::Collections::IKeyValuePair<hstring, IInspectable> ClassWithMarshalingRoutines::createKeyValuePairObject()
{
Windows::Foundation::Collections::ValueSet valueSet;
valueSet.Insert(hstring(L"key"), PropertyValue::CreateInt32(27861));
return valueSet.First().Current();
}
Windows::Foundation::IReference<INT32> ClassWithMarshalingRoutines::createNullableObject()
{
return IReference<INT32>(123);
}
Windows::Foundation::IReferenceArray<int> ClassWithMarshalingRoutines::createArrayObject()
{
int values[]{ 0, 42, 1729, -1 };
auto propertyValue = PropertyValue::CreateInt32Array(values).as<IPropertyValue>();
return propertyValue.as<IReferenceArray<int>>();
}
Windows::Foundation::IInspectable ClassWithMarshalingRoutines::NewTypeErasedKeyValuePairObject()
{
return createKeyValuePairObject();
}
void ClassWithMarshalingRoutines::NewTypeErasedKeyValuePairObject(Windows::Foundation::IInspectable val)
{
}
Windows::Foundation::IInspectable ClassWithMarshalingRoutines::NewTypeErasedNullableObject()
{
return createNullableObject();
}
void ClassWithMarshalingRoutines::NewTypeErasedNullableObject(Windows::Foundation::IInspectable val)
{
}
Windows::Foundation::IInspectable ClassWithMarshalingRoutines::NewTypeErasedArrayObject()
{
return createArrayObject();
}
void ClassWithMarshalingRoutines::NewTypeErasedArrayObject(Windows::Foundation::IInspectable val)
{
}
Windows::Foundation::IInspectable ClassWithMarshalingRoutines::ExistingTypeErasedKeyValuePairObject()
{
return keyValuePairObject;
}
void ClassWithMarshalingRoutines::ExistingTypeErasedKeyValuePairObject(Windows::Foundation::IInspectable val)
{
}
Windows::Foundation::IInspectable ClassWithMarshalingRoutines::ExistingTypeErasedNullableObject()
{
return nullableObject;
}
void ClassWithMarshalingRoutines::ExistingTypeErasedNullableObject(Windows::Foundation::IInspectable val)
{
}
Windows::Foundation::IInspectable ClassWithMarshalingRoutines::ExistingTypeErasedArrayObject()
{
return arrayObject;
}
void ClassWithMarshalingRoutines::ExistingTypeErasedArrayObject(Windows::Foundation::IInspectable val)
{
}
BenchmarkComponent::WrappedClass ClassWithMarshalingRoutines::NewWrappedClassObject()
{
return make<WrappedClass>();
}
void ClassWithMarshalingRoutines::NewWrappedClassObject(BenchmarkComponent::WrappedClass val)
{
}
WrappedClass::WrappedClass()
{
}
int32_t WrappedClass::DefaultIntProperty()
{
return int32_t();
}
void WrappedClass::DefaultIntProperty(int32_t val)
{
}
}

Просмотреть файл

@ -1,6 +1,8 @@
#pragma once
#include "ClassWithMultipleInterfaces.g.h"
#include "ClassWithMarshalingRoutines.g.h"
#include "WrappedClass.g.h"
namespace winrt::BenchmarkComponent::implementation
{
@ -24,6 +26,53 @@ namespace winrt::BenchmarkComponent::implementation
void DefaultBoolProperty(bool val);
void DefaultDoubleProperty(double val);
};
struct WrappedClass : WrappedClassT<WrappedClass>
{
WrappedClass();
int32_t DefaultIntProperty();
void DefaultIntProperty(int32_t val);
};
struct ClassWithMarshalingRoutines : ClassWithMarshalingRoutinesT<ClassWithMarshalingRoutines>
{
private:
Windows::Foundation::Collections::IKeyValuePair<hstring, IInspectable> keyValuePairObject;
Windows::Foundation::IReference<INT32> nullableObject;
Windows::Foundation::IReferenceArray<int> arrayObject;
Windows::Foundation::Collections::IKeyValuePair<hstring, IInspectable> createKeyValuePairObject();
Windows::Foundation::IReference<INT32> createNullableObject();
Windows::Foundation::IReferenceArray<int> createArrayObject();
public:
ClassWithMarshalingRoutines();
hstring DefaultStringProperty();
void DefaultStringProperty(hstring val);
Windows::Foundation::IInspectable NewTypeErasedKeyValuePairObject();
void NewTypeErasedKeyValuePairObject(Windows::Foundation::IInspectable val);
Windows::Foundation::IInspectable NewTypeErasedNullableObject();
void NewTypeErasedNullableObject(Windows::Foundation::IInspectable val);
Windows::Foundation::IInspectable NewTypeErasedArrayObject();
void NewTypeErasedArrayObject(Windows::Foundation::IInspectable val);
Windows::Foundation::IInspectable ExistingTypeErasedKeyValuePairObject();
void ExistingTypeErasedKeyValuePairObject(Windows::Foundation::IInspectable val);
Windows::Foundation::IInspectable ExistingTypeErasedNullableObject();
void ExistingTypeErasedNullableObject(Windows::Foundation::IInspectable val);
Windows::Foundation::IInspectable ExistingTypeErasedArrayObject();
void ExistingTypeErasedArrayObject(Windows::Foundation::IInspectable val);
BenchmarkComponent::WrappedClass NewWrappedClassObject();
void NewWrappedClassObject(BenchmarkComponent::WrappedClass val);
};
}
namespace winrt::BenchmarkComponent::factory_implementation
@ -31,4 +80,12 @@ namespace winrt::BenchmarkComponent::factory_implementation
struct ClassWithMultipleInterfaces : ClassWithMultipleInterfacesT<ClassWithMultipleInterfaces, implementation::ClassWithMultipleInterfaces>
{
};
struct ClassWithMarshalingRoutines : ClassWithMarshalingRoutinesT<ClassWithMarshalingRoutines, implementation::ClassWithMarshalingRoutines>
{
};
struct WrappedClass : WrappedClassT<WrappedClass, implementation::WrappedClass>
{
};
}

Просмотреть файл

@ -32,4 +32,30 @@ namespace BenchmarkComponent
Boolean DefaultBoolProperty{ get; set; };
Double DefaultDoubleProperty{ get; set; };
}
[default_interface]
runtimeclass WrappedClass
{
WrappedClass();
Int32 DefaultIntProperty{ get; set; };
}
[default_interface]
runtimeclass ClassWithMarshalingRoutines
{
ClassWithMarshalingRoutines();
String DefaultStringProperty{ get; set; };
IInspectable NewTypeErasedKeyValuePairObject{ get; set; };
IInspectable NewTypeErasedNullableObject{ get; set; };
IInspectable NewTypeErasedArrayObject{ get; set; };
IInspectable ExistingTypeErasedKeyValuePairObject{ get; set; };
IInspectable ExistingTypeErasedNullableObject{ get; set; };
IInspectable ExistingTypeErasedArrayObject{ get; set; };
WrappedClass NewWrappedClassObject{ get; set; };
}
}