-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of http://git.newlifex.com/NewLife/NewLife.Redis
- Loading branch information
Showing
17 changed files
with
153 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System.Security.Cryptography; | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Engines; | ||
using NewLife.Caching; | ||
using NewLife.Security; | ||
|
||
namespace Benchmark; | ||
|
||
[SimpleJob(RunStrategy.ColdStart, iterationCount: 1)] | ||
[MemoryDiagnoser] | ||
public class BasicBenchmark | ||
{ | ||
public FullRedis Redis { get; set; } | ||
|
||
private String[] _keys; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
var rds = new FullRedis | ||
{ | ||
Tracer = DefaultTracer.Instance, | ||
Log = XTrace.Log, | ||
}; | ||
rds.Init("server=127.0.0.1:6379;password=;db=3;timeout=5000"); | ||
|
||
Redis = rds; | ||
|
||
var ks = new String[100_000]; | ||
for (var i = 0; i < ks.Length; i++) | ||
{ | ||
ks[i] = Rand.NextString(16); | ||
} | ||
_keys = ks; | ||
} | ||
|
||
[Benchmark] | ||
public void GetTest() | ||
{ | ||
var rds = Redis; | ||
|
||
for (var i = 0; i < _keys.Length; i++) | ||
{ | ||
var value = rds.Get<String>(_keys[i]); | ||
} | ||
} | ||
|
||
[Benchmark] | ||
public void SetTest() | ||
{ | ||
var rds = Redis; | ||
var value = Rand.NextString(16); | ||
|
||
for (var i = 0; i < _keys.Length; i++) | ||
{ | ||
rds.Set(_keys[i], value); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<AssemblyTitle>应用后台任务</AssemblyTitle> | ||
<Description>数据处理、定时任务、MQ生产消费、系统监控等超长独立工作的后台任务</Description> | ||
<Company>新生命开发团队</Company> | ||
<Copyright>©2002-2024 NewLife</Copyright> | ||
<VersionPrefix>1.0</VersionPrefix> | ||
<VersionSuffix>$([System.DateTime]::Now.ToString(`yyyy.MMdd`))</VersionSuffix> | ||
<Version>$(VersionPrefix).$(VersionSuffix)</Version> | ||
<FileVersion>$(Version)</FileVersion> | ||
<OutputPath>..\..\Bin\Benchmark</OutputPath> | ||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Using Include="NewLife" /> | ||
<Using Include="NewLife.Log" /> | ||
<Using Include="NewLife.Model" /> | ||
<Using Include="NewLife.Reflection" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" /> | ||
<PackageReference Include="NewLife.Stardust" Version="3.2.2024.1211" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\NewLife.Redis\NewLife.Redis.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Benchmark; | ||
using BenchmarkDotNet.Running; | ||
using NewLife.Caching; | ||
using Stardust; | ||
|
||
//!!! 标准后台服务项目模板,新生命团队强烈推荐 | ||
|
||
// 启用控制台日志,拦截所有异常 | ||
XTrace.UseConsole(); | ||
|
||
// 初始化对象容器,提供依赖注入能力 | ||
var services = ObjectContainer.Current; | ||
services.AddSingleton(XTrace.Log); | ||
|
||
// 配置星尘。自动读取配置文件 config/star.config 中的服务器地址 | ||
var star = services.AddStardust(); | ||
|
||
var summary = BenchmarkRunner.Run<BasicBenchmark>(); | ||
|
||
Console.ReadLine(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft": "Warning", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
}, | ||
"AllowedHosts": "*", | ||
//"StarServer": "http://s.newlifex.com:6600", | ||
//"RedisCache": "server=127.0.0.1:6379;password=;db=3", | ||
//"RedisQueue": "server=127.0.0.1:6379;password=;db=5", | ||
"ConnectionStrings": { | ||
"Zero": "Data Source=..\\Data\\Zero.db;Provider=SQLite" | ||
|
||
// 各种数据库连接字符串模版,连接名Zero对应Zero.Data/Projects/Model.xml中的ConnName | ||
//"Zero": "Server=.;Port=3306;Database=zero;Uid=root;Pwd=root;Provider=MySql", | ||
//"Zero": "Data Source=.;Initial Catalog=zero;user=sa;password=sa;Provider=SqlServer", | ||
//"Zero": "Server=.;Database=zero;Uid=root;Pwd=root;Provider=PostgreSql", | ||
//"Zero": "Data Source=Tcp://127.0.0.1/ORCL;User Id=scott;Password=tiger;Provider=Oracle" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters