Adjust assets, analytics
This commit is contained in:
Родитель
2ab6dbfa4e
Коммит
407b8de54c
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 7.5 KiB После Ширина: | Высота: | Размер: 25 KiB |
|
@ -12,6 +12,7 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Threading.Tasks;
|
||||
using Uno.Foundation;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.UI;
|
||||
|
@ -61,12 +62,16 @@ namespace BenchmarkDotNet.Live.Shared
|
|||
|
||||
private async Task Run()
|
||||
{
|
||||
#if __WASM__
|
||||
WebAssemblyRuntime.InvokeJS("Uno.UI.Demo.Analytics.reportPageView('benchmarkRun');");
|
||||
#endif
|
||||
|
||||
runButton.IsEnabled = false;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
await SetStatus($"Building source");
|
||||
await SetStatus($"Compiling source");
|
||||
var config = new CoreConfig(_logger);
|
||||
|
||||
var assembly = await SampleRunner.Build(sources.Text);
|
||||
|
@ -93,13 +98,6 @@ namespace BenchmarkDotNet.Live.Shared
|
|||
await Task.Yield();
|
||||
}
|
||||
|
||||
private IEnumerable<Type> EnumerateBenchmarks(IConfig config)
|
||||
=> from type in GetType().GetTypeInfo().Assembly.GetTypes()
|
||||
where !type.IsGenericType
|
||||
where type.Namespace?.StartsWith(BenchmarksBaseNamespace) ?? false
|
||||
where BenchmarkConverter.TypeToBenchmarks(type, config).BenchmarksCases.Length != 0
|
||||
select type;
|
||||
|
||||
public class CoreConfig : ManualConfig
|
||||
{
|
||||
public CoreConfig(ILogger logger)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
LinkToOriginalApp="https://github.com/dotnet/BenchmarkDotNet"
|
||||
AppName="BenchmarkDotNet Live"
|
||||
AppAuthor="Uno Platform">
|
||||
<local:BenchmarkControl Grid.Row="1" />
|
||||
<local:BenchmarkControl Grid.Row="1" />
|
||||
</banner:BannerControl>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<DefineConstants>$(DefineConstants);__WASM__</DefineConstants>
|
||||
<NoWarn>NU1701</NoWarn>
|
||||
<WasmShellGenerateCompressedFiles Condition="'$(Configuration)'!='Release'">false</WasmShellGenerateCompressedFiles>
|
||||
<TypeScriptToolsVersion>3.3</TypeScriptToolsVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\BenchmarkDotNet.Live.UWP\Assets\*.png" Link="Assets\%(FileName)%(Extension)" />
|
||||
|
@ -14,15 +15,28 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="WasmCSS\Fonts.css" />
|
||||
<EmbeddedResource Include="WasmScripts\AppManifest.js" />
|
||||
<EmbeddedResource Include="WasmScripts\*.js" />
|
||||
<EmbeddedResource Include="mono-sdk\*.dll" />
|
||||
<EmbeddedResource Include="..\..\..\src\BenchmarkDotNet\bin\$(Configuration)\netstandard2.0\BenchmarkDotNet.dll" Link="mono-sdk\BenchmarkDotNet.dll" />
|
||||
<EmbeddedResource Include="..\..\..\src\BenchmarkDotNet\bin\$(Configuration)\netstandard2.0\BenchmarkDotNet.Annotations.dll" Link="mono-sdk\BenchmarkDotNet.Annotations.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WasmShellMonoEnvironment Include="MONO_GC_PARAMS" Value="soft-heap-limit=512m,nursery-size=64m,evacuation-threshold=66,major=marksweep" />
|
||||
<WasmShellMonoEnvironment Include="MONO_LOG_LEVEL" Value="debug" />
|
||||
<WasmShellMonoEnvironment Include="MONO_LOG_MASK" Value="gc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<LinkerDescriptor Include="LinkerConfig.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.TypeScript.Compiler" Version="3.1.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="3.3.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Uno.UI" Version="1.45.0-dev.1067" />
|
||||
<PackageReference Include="Uno.Wasm.Bootstrap" Version="1.0.0-dev.236" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis" Version="2.10.0" />
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Uno.Foundation;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
namespace BenchmarkDotNet.Live.Wasm
|
||||
|
@ -9,6 +10,8 @@ namespace BenchmarkDotNet.Live.Wasm
|
|||
|
||||
static int Main(string[] args)
|
||||
{
|
||||
WebAssemblyRuntime.InvokeJS("Uno.UI.Demo.Analytics.reportPageView('main');");
|
||||
|
||||
Windows.UI.Xaml.Application.Start(_ => _app = new App());
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
var UnoAppManifest = {
|
||||
|
||||
splashScreenImage: "Assets/SplashScreen.scale-200.png",
|
||||
splashScreenColor: "#00f",
|
||||
splashScreenColor: "#fff",
|
||||
displayName: "BenchmarkDotNet Live"
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
var Uno;
|
||||
(function (Uno) {
|
||||
var UI;
|
||||
(function (UI) {
|
||||
var Demo;
|
||||
(function (Demo) {
|
||||
class Analytics {
|
||||
static reportPageView(screenName, appName = "Uno.BenchmarkDotNet") {
|
||||
if (Analytics.init(screenName, appName)) {
|
||||
return "ok";
|
||||
}
|
||||
const gtag = window.gtag;
|
||||
if (gtag) {
|
||||
gtag("event", "screen_view", {
|
||||
screen_name: screenName,
|
||||
app_name: appName
|
||||
});
|
||||
}
|
||||
else {
|
||||
console.error(`Google Analytics not present, can't report page view for ${screenName}.`);
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
static init(screenName, appName) {
|
||||
if (Analytics.isLoaded) {
|
||||
return false;
|
||||
}
|
||||
const script = `
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() { dataLayer.push(arguments); }
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-26688675-14');
|
||||
|
||||
gtag("event", "screen_view", {screen_name: \"${screenName}\", app_name: \"${appName}\"});`;
|
||||
const script1 = document.createElement("script");
|
||||
script1.type = "text/javascript";
|
||||
script1.src = "https://www.googletagmanager.com/gtag/js?id=UA-26688675-14";
|
||||
document.body.appendChild(script1);
|
||||
const script2 = document.createElement("script");
|
||||
script2.type = "text/javascript";
|
||||
script2.innerText = script;
|
||||
document.body.appendChild(script2);
|
||||
Analytics.isLoaded = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Analytics.isLoaded = false;
|
||||
Demo.Analytics = Analytics;
|
||||
})(Demo = UI.Demo || (UI.Demo = {}));
|
||||
})(UI = Uno.UI || (Uno.UI = {}));
|
||||
})(Uno || (Uno = {}));
|
|
@ -0,0 +1,53 @@
|
|||
namespace Uno.UI.Demo {
|
||||
export class Analytics {
|
||||
private static isLoaded: boolean = false;
|
||||
|
||||
public static reportPageView(screenName: string, appName: string = "Uno.BenchmarkDotNet"): string {
|
||||
|
||||
if (Analytics.init(screenName, appName)) {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
const gtag = (window as any).gtag;
|
||||
if (gtag) {
|
||||
gtag("event",
|
||||
"screen_view",
|
||||
{
|
||||
screen_name: screenName,
|
||||
app_name: appName
|
||||
});
|
||||
} else {
|
||||
console.error(`Google Analytics not present, can't report page view for ${screenName}.`);
|
||||
}
|
||||
|
||||
return "ok";
|
||||
}
|
||||
|
||||
private static init(screenName: string, appName: string): boolean {
|
||||
if (Analytics.isLoaded) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const script = `
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() { dataLayer.push(arguments); }
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-26688675-14');
|
||||
|
||||
gtag("event", "screen_view", {screen_name: \"${screenName}\", app_name: \"${appName}\"});`;
|
||||
|
||||
|
||||
const script1 = document.createElement("script");
|
||||
script1.type = "text/javascript";
|
||||
script1.src = "https://www.googletagmanager.com/gtag/js?id=UA-26688675-14";
|
||||
document.body.appendChild(script1);
|
||||
const script2 = document.createElement("script");
|
||||
script2.type = "text/javascript";
|
||||
script2.innerText = script;
|
||||
document.body.appendChild(script2);
|
||||
|
||||
Analytics.isLoaded = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "none",
|
||||
"declaration": false,
|
||||
"diagnostics": true,
|
||||
"noImplicitAny": true,
|
||||
"outFile": "WasmScripts/gallery.js",
|
||||
"locale": "en-US",
|
||||
"target": "es2015"
|
||||
},
|
||||
"include": [
|
||||
"ts/**/*.ts"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<customErrors mode="Off"/>
|
||||
</system.web>
|
||||
|
||||
<system.webServer>
|
||||
|
||||
<!-- Disable compression as we're doing it throuh pre-compressed files -->
|
||||
<urlCompression doStaticCompression="false" doDynamicCompression="false" dynamicCompressionBeforeCache="false" />
|
||||
|
||||
<staticContent>
|
||||
<remove fileExtension=".dll" />
|
||||
<remove fileExtension=".wasm" />
|
||||
<remove fileExtension=".woff" />
|
||||
<remove fileExtension=".woff2" />
|
||||
<mimeMap fileExtension=".wasm" mimeType="application/wasm" />
|
||||
<mimeMap fileExtension=".clr" mimeType="application/octet-stream" />
|
||||
<mimeMap fileExtension=".pdb" mimeType="application/octet-stream" />
|
||||
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
|
||||
<mimeMap fileExtension=".woff2" mimeType="application/font-woff" />
|
||||
|
||||
<!-- Required for PWAs -->
|
||||
<mimeMap fileExtension=".json" mimeType="application/octet-stream" />
|
||||
|
||||
</staticContent>
|
||||
|
||||
<rewrite>
|
||||
<rules>
|
||||
<rule name="Lookup for pre-compressed brotli file" stopProcessing="true">
|
||||
<match url="(.*)$"/>
|
||||
<conditions>
|
||||
<!-- Match brotli requests -->
|
||||
<add input="{HTTP_ACCEPT_ENCODING}" pattern="br" />
|
||||
|
||||
<!-- Match all but pre-compressed files -->
|
||||
<add input="{REQUEST_URI}" pattern="^(?!/_compressed_br/)(.*)$" />
|
||||
|
||||
<!-- Check if the pre-compressed file exists on the disk -->
|
||||
<add input="{DOCUMENT_ROOT}/_compressed_br/{C:0}" matchType="IsFile" negate="false" />
|
||||
</conditions>
|
||||
<action type="Rewrite" url="/_compressed_br{C:0}" />
|
||||
</rule>
|
||||
|
||||
<rule name="Lookup for pre-compressed gzip file" stopProcessing="true">
|
||||
<match url="(.*)$"/>
|
||||
<conditions>
|
||||
<!-- Match gzip requests -->
|
||||
<add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip" />
|
||||
|
||||
<!-- Match all but pre-compressed files -->
|
||||
<add input="{REQUEST_URI}" pattern="^(?!/_compressed_gz/)(.*)$" />
|
||||
|
||||
<!-- Check if the pre-compressed file exists on the disk -->
|
||||
<add input="{DOCUMENT_ROOT}/_compressed_gz/{C:0}" matchType="IsFile" negate="false" />
|
||||
</conditions>
|
||||
<action type="Rewrite" url="/_compressed_gz{C:0}" />
|
||||
</rule>
|
||||
</rules>
|
||||
|
||||
<outboundRules>
|
||||
<rule name="Adjust content encoding for gzip pre-compressed files" enabled="true" stopProcessing="true">
|
||||
<match serverVariable="RESPONSE_CONTENT_ENCODING" pattern="" />
|
||||
<conditions>
|
||||
<add input="{REQUEST_URI}" pattern="/_compressed_gz/.*$" />
|
||||
</conditions>
|
||||
<action type="Rewrite" value="gzip"/>
|
||||
</rule>
|
||||
<rule name="Adjust content encoding for brotli pre-compressed files" enabled="true" stopProcessing="true">
|
||||
<match serverVariable="RESPONSE_CONTENT_ENCODING" pattern="" />
|
||||
<conditions>
|
||||
<add input="{REQUEST_URI}" pattern="/_compressed_br/.*$" />
|
||||
</conditions>
|
||||
<action type="Rewrite" value="br"/>
|
||||
</rule>
|
||||
</outboundRules>
|
||||
</rewrite>
|
||||
</system.webServer>
|
||||
</configuration>
|
Загрузка…
Ссылка в новой задаче