2025-06-04 22:49:37 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
|
using PY2HZ;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using Debug = UnityEngine.Debug;
|
|
|
|
|
|
|
|
|
|
namespace HK
|
|
|
|
|
{
|
|
|
|
|
public class Test : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
PinYin4HanZi pinYin4HanZi;
|
|
|
|
|
public string py;
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
pinYin4HanZi = new PinYin4HanZi();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
{
|
2025-07-13 15:53:13 +08:00
|
|
|
|
return;
|
2025-06-04 22:49:37 +08:00
|
|
|
|
if (Input.GetKeyDown(KeyCode.A))
|
|
|
|
|
{
|
|
|
|
|
Stopwatch stopwatch = new Stopwatch();
|
|
|
|
|
stopwatch.Start();
|
|
|
|
|
|
|
|
|
|
UniTask.Void(async () =>
|
|
|
|
|
{
|
|
|
|
|
Stopwatch stopwatch1 = new Stopwatch();
|
|
|
|
|
stopwatch1.Start();
|
|
|
|
|
var hanZiAsync = await PinYin4HanZi.GetHanZiAsync(py);
|
|
|
|
|
foreach (var se in hanZiAsync)
|
|
|
|
|
{
|
|
|
|
|
// Debug.Log(se);
|
|
|
|
|
}
|
|
|
|
|
Debug.Log(hanZiAsync.Length);
|
|
|
|
|
stopwatch1.Stop();
|
|
|
|
|
Debug.Log($"1执行时间: {stopwatch1.ElapsedMilliseconds} 毫秒");
|
|
|
|
|
});
|
|
|
|
|
var hanZi = PinYin4HanZi.GetHanZi(py);
|
|
|
|
|
Debug.Log(hanZi.Length);
|
|
|
|
|
foreach (var se in hanZi)
|
|
|
|
|
{
|
|
|
|
|
// Debug.Log(se);
|
|
|
|
|
}
|
|
|
|
|
stopwatch.Stop();
|
|
|
|
|
Debug.Log($"执行时间: {stopwatch.ElapsedMilliseconds} 毫秒");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|