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() { return; 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} 毫秒"); } } } }