Java代码优化札记

告别盲目调参:手把手教你用RKISP2.x Tuner理解AWB、AE、NR等核心模块 本文详细介绍了如何使用RKISP2.x Tuner工具进行ISP调试,重点解析AWB、AE、NR等核心模块的调参技巧。通过RV1126平台的实际操作演示,帮助工程师快速掌握可视化对比实验方法,告别盲目调参,提升图像信号处理效率。 阅读详情

避免在循环条件中使用复杂表达式


在不做编译优化的情况下,在循环中,循环条件会被反复计算。


为HashMap等定义初始大小


HashMap等结构在扩容的时候需要耗费一定的资源,所以在定义时最好能够估计所需的大小。


在finally中关闭stream


在finally块中释放资源stream,因为不管程序执行的结果如何,finally总会执行。


使用system.arraycopy()代替通过循环赋值数组


设置getter/setter方法变成“final”

这样编译器会视为内联函数,所谓内联函数就是指函数在被调用的地方直接展开,编译器在调用时不用像一般函数那样,参数压栈,返回时参数出栈以及资源释放等,这样提高了程序执行速度。


不在循环中调用synchronized方法,将try/catch块溢出循环


String和StringBuffer的使用取舍


使用条件操作符替代“if() return;else return;"


尽可能使用栈变量,访问静态变量和实例变量将会比访问局部变量耗费更多的时间,调用方法时传递的参数以及在调用中创建的临时变量都保存在栈中,速度较快。静态变量,实例变量等,都在堆中创建,速度较慢。


尽量不要在循环体中实例化变量


HashMap,ArrayList,StringBuilder之于HashTable,Vector,StringBuffer,线程安全和效率。









DDR5内存ODT模式全解析:5种状态与实战配置指南(附时序图) 本文深入解析DDR5内存的片上终端电阻(ODT)机制,详细阐述了其五种核心状态(终结电阻禁用、RTT_WR、RTT_NOM_RD、RTT_NOM_WR、RTT_PARK)的定义、切换时序与工作原理。通过解读JESD79-5规范中的时序图,并提供基于模式寄存器的实战配置指南与代码示例,帮助硬件工程师和系统开发者优化信号完整性,解决高负载下的稳定性问题,并实现性能与功耗的最佳平衡。 阅读详情

相关推荐

智能车‘大脑’的诞生:揭秘电磁循迹代码背后的控制论与系统思维

本文深入探讨智能车电磁循迹系统的核心架构与控制原理,揭示了其作为精密闭环系统如何通过模块化设计、信号处理、PID控制算法及电机驱动实现自主导航。重点分析了电磁信号采集与处理流程框架,为开发者提供从理论到实践的全面指南。

arduino9maker的博客 533

读书札记(一)

1: 最近在看《编程卓越之道-深入理解计算机》,这本书确实是本值得一看的书,至少对得起你的49个大洋,呵呵. 作者是《汇编语言编程艺术》一书的作者.从很深刻的角度分析了CPU、内存、总线之间的代码优化方法和原理. 比如下面的代码: public class TestSpeed{public static void main(String[] args){int[][] array = ne...

编程开发资料库 164

一文入门BMS(电池管理系统)

本文章是基于曾师兄的文稿《具有组网扩展功能的新能源汽车电池管理系统》而写的文章。该文章主要是对BMS(Battery Management System,电池管理系统)做一些简要的介绍,借此助各位也助我入门BMS。有纰漏请指出,转载请说明。学习交流请发邮件 1280253714@qq.com。

weixin_45817947的博客 2万+

java学习札记之java新特性对数组的支持

1、新特性之一:可变参数--- 可变参数:即在方法中接受的参数不再是固定的,而是随着需要传递的; 可变参数的格式:返回值类型 方法名称(类型、、、参数名称){};向方法中传递可变参数后,其中的参数是以数组的形式保存下来的; eg: public class VariableParameter { public static void main(String args[]){ Syst

95

ROS小车定位实战:如何用rf2o_laser_odometry和robot_localization实现精准里程计(附避坑指南)

本文详细介绍了如何利用rf2o_laser_odometry和robot_localization在ROS中实现高精度小车定位。通过激光里程计与状态估计的黄金组合,解决室内移动机器人的定位难题,包括环境搭建、算法配置、多传感器融合策略及实战避坑指南,帮助开发者快速部署稳定可靠的定位系统。

weixin_29081703的博客 287

【魔兽世界插件】魔兽世界插件实战笔记从入门到放弃的心理历程 第一节 lua框架的建立

魔兽世界插件实战笔记从入门到放弃的心理历程 第二节 lua框架的建立 找到魔兽世界的安装目录,找到插件的默认位置:\World of Warcraft\_retail_\Interface\AddOns,在这里建立一个文件夹,魔兽的插件都是用一个文件夹来区分的,第一课吗,就用Lesson_one吧。 下面建立的三个文件,第一个点toc文件是最重要的一个,它是魔兽客户端识别插件的一个标识符。 魔兽版本号有一个函数可以查询在WoWLua下面运行:print("当前游戏版本号:",(select(4,GetBui

qq_33075391的博客 6451

代码整洁之道札记:代码为什么要整洁

前言:一直以来,我都非常喜欢整洁规则的代码,我痛恶那些杂乱不堪的代码,然而《代码整洁之道》将要告诉我的远不止这些,那么,我希望将自己欣赏的、能够给我帮助的、指引我前进的方案记录下来,以用来我日后翻看。 要有代码 将需求明确到机器可以执行的细节程度,是编程要做的事。一个好的产品,显然其最精髓的不应该是外观,而是诸如Java编译后的class文件。 糟糕的代码 看到“糟糕”这个词就觉得可怕,我

沉默王二 1921

VL53L0X测距不准?手把手教你做RefSPAD校准与环境补偿(附Arduino/STM32代码)

本文详细解析了VL53L0X激光测距传感器精度不足的原因,并提供了RefSPAD校准与环境补偿的完整解决方案。通过Arduino和STM32代码示例,手把手教你实现毫米级测距稳定性,适用于机器人避障、工业检测等场景。

weixin_28744423的博客 258

Node.js学习札记:Node.js主要特性

1、共享状态的并发

qq_21086757的专栏 248

IOS APP上架被拒 4.3(a) - Design - Spam,成功

成功解决IOS APP上架被拒 4.3(a) - Design - Spam,本篇博客记录了详细过程

qq_40147106的博客 6918

BGE(BAAI General Embedding)模型详解

BGE(BAAI General Embedding)是北京智源人工智能研究院(BAAI)推出的通用文本嵌入模型系列,旨在为各种自然语言处理任务提供高质量的向量表示。

ttyy1112的专栏 7563

2016文章汇总

Java系列:JVM系列:jvm基本结构JVM系列:java中JVM的原理JVM系列:解决JVM最大内存设置问题JVM系列:JVM参数设置、分析HashMap , HashTable , ConcurrentHashMap 源码比较从使用到原理学习Java线程池谈谈HashMap线程不安全的体现Java NIO浅析解密ThreadLocalJAVA虚拟机体系结...

weixin_33810006的博客 159

V4L2教程(1):Ubuntu V4L2开发环境搭建与设备探索

欢迎来到V4L2学习指南的第一篇!本文将带你从零开始,在Ubuntu系统上搭建完整的V4L2视频采集开发环境。无论你是想开发视频监控、视频会议还是机器视觉应用,掌握V4L2都是Linux视频开发的必经之路。 **本节学习目标**: - 理解V4L2的基本概念和架构 - 搭建Ubuntu下的V4L2开发环境 - 掌握v4l2-ctl等调试工具的使用 - 学会检测和配置USB摄像头设备

琅嬛福地 417

InnoDB 内存结构总览:Change Buffer、AHI 与 Log Buffer

本文系统梳理InnoDB内存结构中的ChangeBuffer、Adaptive Hash Index(AHI)与LogBuffer。ChangeBuffer缓存二级索引页不在内存时的变更,减少随机IO,仅在页加载时合并;聚簇索引修改立即执行,因数据本身不可延后。AHI基于高频等值查询自动构建哈希索引,加速定位,仅支持等值操作。LogBuffer为redo log内存缓冲,配合磁盘日志实现崩溃恢复。三者均服务于性能优化,其中ChangeBuffer与AHI共享BufferPool空间,而LogBuffer独立

bksczm的博客 306

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

信创环境下PageOffice文档控件适配与实践

信创适配做到文档控件这一层,拼的已经不是"有没有国产版本",而是同一个功能在两类终端上是否真的等价。等价的标准很具体:同一次点击能得到同样的结果,同一份公文能得到同样的版式,同一个项目不需要维护两套代码。这背后是三件并不轻松的工作:服务端用一套接口同时支撑两类终端,客户端把两种系统与四种芯片的安装包分发清楚,文档内核层由产品侧跟着 WPS 的版本走。浏览器这一层的压力,则被收进了产品自己的窗口里——升级节奏由产品掌握,不再交给运气。

zi_wu_xian的专栏 333

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

第三篇 第 6 课

前置:第三篇第 1 课(stdx 引入),第二篇第 1 课(std.regex)。环境:仓颉 SDK 1.2.0。本文所有代码与输出均逐行实测。

weixin_41618057的博客 557

深度学习工具包 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")

【从零理解 Spring AI · 12】MCP 的两种角色:做客户端还是做服务端

上一篇讲了 MCP 的概念:标准协议、三大角色、M+N 替代 M×N。

nice_lcj520的博客 602

Java 集合容器高频面试题全解:HashMap 树化阈值、1.7 死循环与 ConcurrentHashMap 演进(2026 招聘 JD 真题复盘)

HashMap 树化阈值 8 的泊松分布依据、退化阈值 6 的防抖设计、JDK 1.7 头插成环死循环的排查与修复、1.8 尾插后为何仍线程不安全、ConcurrentHashMap 放弃分段锁的原因与 ForwardingNode 协作扩容、computeIfAbsent 死锁陷阱、大集合找重复的场景题选型,附三层追问链自测。题目来源为 38 期公开招聘 JD 样本与字节、拼多多、建行、美团、快手公开面经。

蒙眼过河 425
上一篇: Java并发摘要(一)
下一篇: JVM内存管理概要(《分布式Java应用》中JVM章节摘要)
csdnerrrrr
博客等级 码龄12年 4粉丝 19原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值