Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions nanoFramework.Hardware.Esp32.Rmt.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using nanoFramework.Benchmark;
using System;
using System.Diagnostics;
using System.Threading;

namespace nanoFramework.Hardware.Esp32.Rmt.Benchmarks
{
public class Program
{
public static void Main()
{
#if DEBUG
Console.WriteLine("Benchmarks should be run in a release build.");
Debugger.Break();
return;
#endif

BenchmarkRunner.RunClass(typeof(SerializeCommandsBenchmark));
Thread.Sleep(Timeout.Infinite);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CSharp.BlankApplication")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CSharp.BlankApplication")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using System.Collections;
using nanoFramework.Benchmark;
using nanoFramework.Benchmark.Attributes;

// ReSharper disable InconsistentNaming
namespace nanoFramework.Hardware.Esp32.Rmt.Benchmarks
{

[IterationCount(2000)]
public class SerializeCommandsBenchmark
{
public static readonly RmtCommand Sk6812_OnePulse = new(14, true, 12, false);
public static readonly RmtCommand Sk6812_ZeroPulse = new(7, true, 16, false);
public static readonly RmtCommand Sk6812_ResetCommand = new(500, false, 520, false);

public static readonly RmtCommand Ws2808_OnePulse = new(52, true, 52, false);
public static readonly RmtCommand Ws2808_ZeroPulse = new(14, true, 52, false);
public static readonly RmtCommand Ws2808_ResetCommand = new(1400, false, 1400, false);

public static readonly RmtCommand Ws2812b_OnePulse = new(32, true, 18, false);
public static readonly RmtCommand Ws2812b_ZeroPulse = new(16, true, 34, false);
public static readonly RmtCommand Ws2812b_ResetCommand = new(2000, false, 2000, false);

public static readonly RmtCommand Ws2812c_OnePulse = new(52, true, 52, false);
public static readonly RmtCommand Ws2812c_ZeroPulse = new(14, true, 52, false);
public static readonly RmtCommand Ws2812c_ResetCommand = new(1400, false, 1400, false);

public static readonly RmtCommand Ws2815b_OnePulse = new(52, true, 52, false);
public static readonly RmtCommand Ws2815b_ZeroPulse = new(14, true, 52, false);
public static readonly RmtCommand Ws2815b_ResetCommand = new(1400, false, 1400, false);

public static readonly ArrayList RmtCommandsArrayList = new()
{
Sk6812_OnePulse,
Sk6812_ZeroPulse,
Sk6812_ResetCommand,

Ws2808_OnePulse,
Ws2808_ZeroPulse,
Ws2808_ResetCommand,

Ws2812b_OnePulse,
Ws2812b_ZeroPulse,
Ws2812b_ResetCommand,

Ws2812c_OnePulse,
Ws2812c_ZeroPulse,
Ws2812c_ResetCommand,

Ws2815b_OnePulse,
Ws2815b_ZeroPulse,
Ws2815b_ResetCommand
};

[Benchmark]
public void SerializeCommands_Current()
{
var serializedCommands = RmtCommandSerializer.SerializeCommands(RmtCommandsArrayList);
}

[Benchmark]
public void SerializeCommands_Original()
{
int i = 0;
int remaining;
byte[] binaryCommands = new byte[RmtCommandsArrayList.Count * 4];
foreach (var cmd in RmtCommandsArrayList)
{
// First pair
if ((cmd as RmtCommand).Duration0 <= 255)
{
binaryCommands[0 + i] = (byte)(cmd as RmtCommand).Duration0;
binaryCommands[1 + i] = (byte)((cmd as RmtCommand).Level0 == true ? 128 : 0);
}
else
{
remaining = (cmd as RmtCommand).Duration0 % 256;
binaryCommands[0 + i] = (byte)(remaining);
binaryCommands[1 + i] = (byte)(((cmd as RmtCommand).Level0 ? 128 : 0) + (((cmd as RmtCommand).Duration0 - remaining) / 256));
}

// Second pair
if ((cmd as RmtCommand).Duration1 <= 255)
{
binaryCommands[2 + i] = (byte)(cmd as RmtCommand).Duration1;
binaryCommands[3 + i] = (byte)((cmd as RmtCommand).Level1 ? 128 : 0);
}
else
{
remaining = (cmd as RmtCommand).Duration1 % 256;
binaryCommands[2 + i] = (byte)(remaining);
binaryCommands[3 + i] = (byte)(((cmd as RmtCommand).Level1 ? 128 : 0) + (((cmd as RmtCommand).Duration1 - remaining) / 256));
}
i += 4;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<NanoFrameworkProjectSystemPath>$(MSBuildExtensionsPath)\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath>
</PropertyGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectTypeGuids>{11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectGuid>7c2bc423-f2d8-41dc-a5af-90cfd014ca07</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<FileAlignment>512</FileAlignment>
<RootNamespace>nanoFramework.Hardware.Esp32.Rmt.Benchmarks</RootNamespace>
<AssemblyName>nanoFramework.Hardware.Esp32.Rmt.Benchmarks</AssemblyName>
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<PropertyGroup Label="nanoFramework">
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\nanoFramework.Hardware.Esp32.Rmt\key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<DelaySign>false</DelaySign>
</PropertyGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SerializeCommandsBenchmark.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib">
<HintPath>..\packages\nanoFramework.CoreLibrary.1.17.1\lib\mscorlib.dll</HintPath>
</Reference>
<Reference Include="nanoFramework.Benchmark">
<HintPath>..\packages\nanoFramework.Benchmark.1.0.102\lib\nanoFramework.Benchmark.dll</HintPath>
</Reference>
<Reference Include="nanoFramework.Logging">
<HintPath>..\packages\nanoFramework.Logging.1.1.142\lib\nanoFramework.Logging.dll</HintPath>
</Reference>
<Reference Include="nanoFramework.Runtime.Native">
<HintPath>..\packages\nanoFramework.Runtime.Native.1.7.9\lib\nanoFramework.Runtime.Native.dll</HintPath>
</Reference>
<Reference Include="nanoFramework.System.Collections">
<HintPath>..\packages\nanoFramework.System.Collections.1.5.62\lib\nanoFramework.System.Collections.dll</HintPath>
</Reference>
<Reference Include="nanoFramework.System.Text">
<HintPath>..\packages\nanoFramework.System.Text.1.3.29\lib\nanoFramework.System.Text.dll</HintPath>
</Reference>
<Reference Include="System.Diagnostics.Stopwatch">
<HintPath>..\packages\nanoFramework.System.Diagnostics.Stopwatch.1.2.815\lib\System.Diagnostics.Stopwatch.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\nanoFramework.Hardware.Esp32.Rmt\nanoFramework.Hardware.Esp32.Rmt.nfproj" />
</ItemGroup>
<ItemGroup>
<Content Include="packages.lock.json" />
</ItemGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
<ProjectExtensions>
<ProjectCapabilities>
<ProjectConfigurationsDeclaredAsItems />
</ProjectCapabilities>
</ProjectExtensions>
</Project>
10 changes: 10 additions & 0 deletions nanoFramework.Hardware.Esp32.Rmt.Benchmarks/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="nanoFramework.Benchmark" version="1.0.102" targetFramework="netnano1.0" />
<package id="nanoFramework.CoreLibrary" version="1.17.1" targetFramework="netnano1.0" />
<package id="nanoFramework.Logging" version="1.1.142" targetFramework="netnano1.0" />
<package id="nanoFramework.Runtime.Native" version="1.7.9" targetFramework="netnano1.0" />
<package id="nanoFramework.System.Collections" version="1.5.62" targetFramework="netnano1.0" />
<package id="nanoFramework.System.Diagnostics.Stopwatch" version="1.2.815" targetFramework="netnano1.0" />
<package id="nanoFramework.System.Text" version="1.3.29" targetFramework="netnano1.0" />
</packages>
49 changes: 49 additions & 0 deletions nanoFramework.Hardware.Esp32.Rmt.Benchmarks/packages.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"version": 1,
"dependencies": {
".NETnanoFramework,Version=v1.0": {
"nanoFramework.Benchmark": {
"type": "Direct",
"requested": "[1.0.102, 1.0.102]",
"resolved": "1.0.102",
"contentHash": "J7G0Yq5Ms9Cms/ZZDcmRN/MnFiDs52vQvL7CVcJZ5BcpI9NwdNT/p2ymckkejMPu5bo7watVrcXM/ni3sblx6g=="
},
"nanoFramework.CoreLibrary": {
"type": "Direct",
"requested": "[1.17.1, 1.17.1]",
"resolved": "1.17.1",
"contentHash": "T/iPvP8AeZs/5UeZgVa2cZVbl79ioeRyBJLzx4qvKbE9RE+984AR5WPY4tjGIdXugs1AFUYYnydvuGCpy+P1ww=="
},
"nanoFramework.Logging": {
"type": "Direct",
"requested": "[1.1.142, 1.1.142]",
"resolved": "1.1.142",
"contentHash": "rHeUDLgtYN/PLsJg5kuQdCeT0gBAZRtJbopZvShlVHS88UGMYHjBmr8LvBAIJmq611wDTMqacqG3dxtfjiME3w=="
},
"nanoFramework.Runtime.Native": {
"type": "Direct",
"requested": "[1.7.9, 1.7.9]",
"resolved": "1.7.9",
"contentHash": "ekjQ4lTNVZ5FNrgry6XV0e7ydOSvcDGuAnSaNQewiBQAfSbpTZx3njCwU5SU5wcO+tBqT4wP7K1LNtw7unaUkg=="
},
"nanoFramework.System.Collections": {
"type": "Direct",
"requested": "[1.5.62, 1.5.62]",
"resolved": "1.5.62",
"contentHash": "tqYYxVHnfJU+v4aOwtW5u6oI3DWYx+njaTa2gY3LXkcltHlaNCXD4c5q314Zb17isZiizKXIB+X9vJnwxw1oLA=="
},
"nanoFramework.System.Diagnostics.Stopwatch": {
"type": "Direct",
"requested": "[1.2.815, 1.2.815]",
"resolved": "1.2.815",
"contentHash": "tzJyaSZZ6qrO6lVuo6XwZ8gao57IK3tsVoBlYFNGvTqwsn6CQQzGMBw4GkFbJv71ldFlwh0mGMic2fDvYDZRjA=="
},
"nanoFramework.System.Text": {
"type": "Direct",
"requested": "[1.3.29, 1.3.29]",
"resolved": "1.3.29",
"contentHash": "h7Jbjd8vmNrro/co6s+Zth+OvStgvOiT3RQtlaqa2t6FmnLZGXkF7LAykjLqWeNfHTafGbBLkSMqHw2VHo4Dmg=="
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCopyright("Copyright (c) 2021 nanoFramework contributors")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading