laya随笔-性能优化篇

提升接近7倍编译速度!laya小游戏开发技巧(普通专栏) 视频演讲稿件 B站视频 今天讲的内容是 提升Laya的编译速度 (webpack+增量编译+自动编译 ) 前后对比图如下 Laya自带的编译速度 启用webpack编译 提升速度=7.7/1.27 ≈6.4 倍 (视频演示效果) 开始讲解详细的操作 首先把准备好的素材拷贝到项目跟目录 拷贝完毕后 在终端输入npm run dev,这时后台会执行文件监控任务,只要文件发生变化就会触发增量编译 在浏览器输入既可以看到效果 http://localhost:8080/bin/index.html 为了方便 阅读详情

本篇会讲那些内容

你好! 这是我的第二篇随笔,关于laya性能优化相关内容。大致上以官方laya教程为主,进行一次自我整理,官网教程如下:Link,有需要自取

How to solve Laya性能优化

在我看过官网教程之后,我对性能优化做出如下归纳总结

  1. 性能统计面板介绍
  2. 内存优化方式
  3. 图形渲染性能
  4. cpu优化方式
  5. 其他优化手段

性能统计面板介绍

顾名思义,是调出性能统计面板所使用的的,

Laya.Stat.Show();

调用后就会显示一些被统计的信息,可以相比较与U3d的Profiler

方框内显示的是帧数,下面的Sprite,DrawCall,CurMem都是游戏开发比较常用的词语,可以自行查询和学习,这里就不再更多解释了。

内存优化方式

内存从漫长的历史发展潮流,从4k发展到如今手机都有4g,8g,当然就算是4g,8g ,16g糟糕的代码也不顶用的快,所以我们为让游戏不是那么吃内存,以及以便适应若干年的机器,所以我们就要对此下手,那么内存优化有哪些方式呢?
首先作为一个u3d程序员,还是要阐述一下u3d的内存优化方式,看看哪些能被laya复用

1.EMMM,u3d作为使用c#自动gc的语言,内存优化还真的不容易,总的来说少new对象,少使用高级特性,这里使用对象池,这里laya也能用!!!
当然其实也可以异步回调,不过我们稍后再说

so,我们这里看看laya对象池如何使用
LayaAir引擎提供了对象池类laya.utils.Pool,我们就基于这个类有许多方法
具体就有

Laya.Pool.getItemByclass("string",class)
 //通过对象池创建图片,如对象池中无相应的对象,则根据class类型执行new class()创建
               Laya.pool. recover("string",obj) 
 //对象池回收
《laya 性能优化》基础性能优化 (不断更新添加) 文本优化 不对文本的属性(例如大小、颜色、粗细、斜体、对齐等等)作出任何改变的话。那我们可以使用changeText()来替换文本 阅读详情

相关推荐

laya spine库优化性能16倍。 下载直接替换原文件即可

实测有效提升laya spine 4.0版本16倍有余 优化文档. 链接中的qq并非本人 https://blog.youkuaiyun.com/qq_39162566/article/details/124948997

<视觉>——单目相机的标定(简单原理+Opencv实现)

单目相机的标定原理大致如下: 世界坐标到像素坐标的转换。 期间的参数有S尺度因子,内参矩阵K,旋转矩阵R,平移矩阵T,一共八个未知数。 在Opencv中我们可以方便的根据相机拍摄不同位姿的标定板图片来标定相机,从而求得这些参数,从而可以将相机下的坐标和实际的世界坐标联系起来,求取单应性矩阵H 参考: 单目相机综述:写的特别好 https://www.cnblo...

Kano365的博客 1万+

VSCode里玩转AvaloniaUI:手把手教你搭建跨平台桌面应用开发环境(附.NET 7配置避坑)

本文详细介绍了如何在VSCode中搭建AvaloniaUI跨平台桌面应用开发环境,包括.NET 7配置避坑指南。从环境准备、项目创建到调试优化,手把手教你利用VSCode和Avalonia实现高效开发,特别解决了.NET 7依赖等常见问题,助力开发者快速上手跨平台应用开发。

weixin_28826545的博客 578

ModbusRTU串口读写报文解析

解析MODBUS报文的格式,讨论异常状态、读多个寄存器与写多个寄存器

Serendipitor的博客 9212

SAP资产模块(FI-AA)与总账(FI-GL)数据不一致是财务顾问和会计人员最常遇到的棘手问题之一

SAP资产模块(FI-AA)与总账(FI-GL)数据不一致问题主要源于四大原因:1)违规手工记账(最常见),直接通过总账录入资产科目凭证而未通过资产模块;2)折旧运行问题,包括执行失败、跨年度问题或配置冲突;3)主数据与配置错误,如科目确定或折旧键设置不当;4)业务流程遗漏,如单据未生成凭证或汇率差异。解决方案包括运行对账报表、检查凭证来源、补跑折旧及核对配置。关键预防措施是坚持"资产模块发起→自动生成凭证→总账审核"的标准流程。

金牌架构师 428

AI幻觉缓解的成本效益分析:投入产出比优化

在当今AI技术飞速发展的时代,AI幻觉成为了一个不容忽视的问题。AI幻觉就像是AI在“做梦”,会给出一些不符合实际或者错误的答案。我们这篇文章的目的就是要分析缓解AI幻觉所需要投入的成本和能够获得的效益,看看怎么能让投入和产出的比例达到最优。范围涵盖了常见的AI应用场景,比如智能客服、自动驾驶等领域。接下来,我们会先介绍一些和AI幻觉、成本效益分析相关的术语。然后用一个有趣的故事引出核心概念,解释什么是AI幻觉、成本效益分析等,以及它们之间的关系。

AI 原生应用开发的博客 935

【制作100个Unity游戏之36】用unity从零开始实现类《开心消消乐》的三消类消除解压小游戏

Unity甜品消除游戏开发摘要 本文介绍了使用Unity开发甜品消除游戏的核心实现步骤: 冰块阵列生成 通过GlobalDef定义全局参数(9行7列网格) IceSpawner脚本动态生成网格化冰块阵列 添加Resolution脚本实现多分辨率适配 随机水果生成 创建FruitSpawner作为水果容器 FruitItem脚本管理水果属性(行列索引、类型) 支持动态创建水果精灵并设置位置 关键技术点 使用Instantiate动态生成预制体 通过localPosition精确控制网格布局 分辨率适配算法保持

向宇的博客,专注php/web全栈 unity游戏开发,欢迎大家评论纠错 1291

华为OD机试真题2025双机位C卷 Java&Go 实现【统计员工影响力分数】

华为OD机试真题2025双机位C卷 C语言 实现【统计员工影响力分数】假设你是大型科技公司的数据分析师,负责分析公司内部员工的社交网络。你需要编写一个函数来计算每个员工的影响力分数。影响力分数定义为该员工直接和间接影响的员工数量。 输入描述

MISAYAONE的博客 281

[系统安全] 十六.PE文件逆向基础知识(PE解析和PE编辑工具)

您可能之前看到过我写的类似文章,为什么还要重复撰写呢?只是想更好地帮助初学者了解病毒逆向分析和系统安全,更加成体系且不破坏之前的系列。因此,我重新开设了这个专栏,准备系统整理和深入学习系统安全、逆向分析和恶意代码检测,“系统安全”系列文章会更加聚焦,更加系统,更加深入,也是作者的慢慢成长史。换专业确实挺难的,逆向分析也是块硬骨头,但我也试试,看看自己未来四年究竟能将它学到什么程度,漫漫长征路,偏向虎山行。享受过程,一起加油~ 作者前面介绍了三个漏洞,包括Chrome浏览器保留密码渗透解析、通过Chrome浏

杨秀璋的专栏 1万+

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

上一篇: laya开发游戏随笔(一)怎么让物体动起来
下一篇: laya引擎使用ActionScript坑坑坑!
Drinker俊壳
博客等级 码龄10年 3粉丝 11原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值