Skip to content

Commit

Permalink
Examples: Update dependencies & fix warnings (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
pglombardo authored Apr 2, 2024
1 parent c08c0a9 commit 9da7d17
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 36 deletions.
47 changes: 21 additions & 26 deletions Benchmarks/ClientBenchmarkApp/ClientBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,34 @@ public class ClientBenchmarks : IDisposable
{
private readonly string smallPayload = new string(/*lang=json,strict*/ "{\"interference\": \"1029384\"}");

private HiveMQClient client;
private readonly string payload256k;

private string payload256k;
private readonly string payload256b;

private string payload256b;
private HiveMQClient client;

public ClientBenchmarks()
{
Console.WriteLine("Starting HiveMQ client benchmarks...");
this.client = null!;
this.SetupPayloads();

// Generate a 256 byte payload
var sb = new StringBuilder();
for (var i = 0; i < 256; i++)
{
sb.Append('a');
}

this.payload256b = sb.ToString();

// Generate a 256k payload
sb = new StringBuilder();
for (var i = 0; i < 256 * 1024; i++)
{
sb.Append('a');
}

this.payload256k = sb.ToString();
}

[GlobalSetup]
Expand Down Expand Up @@ -153,26 +170,4 @@ await this.client.PublishAsync(
}

public void Dispose() => GC.SuppressFinalize(this);

private void SetupPayloads()
{
// Generate a 256 byte payload
var sb = new StringBuilder();
for (var i = 0; i < 256; i++)
{
sb.Append('a');
}

this.payload256b = sb.ToString();

// Generate a 256k payload
sb = new StringBuilder();
for (var i = 0; i < 256 * 1024; i++)
{
sb.Append('a');
}

this.payload256k = sb.ToString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="HiveMQtt" Version="0.5.0" />
<PackageReference Include="HiveMQtt" Version="0.11.1" />
</ItemGroup>

</Project>
10 changes: 3 additions & 7 deletions Examples/Reconnect/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Text.Json;
using System.Diagnostics;
using HiveMQtt.Client;
using HiveMQtt.Client.Exceptions;
using HiveMQtt.Client.Options;
using System.Text.Json;
using System.Diagnostics;

var topic = "hivemqtt/waiting/game";

Expand Down Expand Up @@ -122,11 +122,7 @@
Console.WriteLine("Publishing a test message...");
var resultPublish = await client.PublishAsync(
topic,
JsonSerializer.Serialize(new
{
Command = "Hello",
})
).ConfigureAwait(false);
JsonSerializer.Serialize(new { Command = "Hello", })).ConfigureAwait(false);

while (true)
{
Expand Down
2 changes: 1 addition & 1 deletion Examples/Reconnect/Reconnect.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="HiveMQtt" Version="0.5.0" />
<PackageReference Include="HiveMQtt" Version="0.11.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Examples/SendMessageOnLoop/SendMessageOnLoop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="HiveMQtt" Version="0.5.0" />
<PackageReference Include="HiveMQtt" Version="0.11.1" />
</ItemGroup>

</Project>

0 comments on commit 9da7d17

Please sign in to comment.