当前位置: 代码迷 >> 综合 >> 【经验总结】写代码必备习惯之解读版本更新以及README
  详细解决方案

【经验总结】写代码必备习惯之解读版本更新以及README

热度:13   发布时间:2023-12-17 14:25:45.0

写代码必备习惯之解读版本更新以及README

目录

写代码必备习惯之解读版本更新以及README

 前言

1.CHANGELOG-hdck解读

2.CHANGELOG-Oprofile解读

3.README-FIO解读

4.README-Oprofile解读



 前言

   我们在写代码的过程中难免会遇到要写版本变更文件和README文件(小型用户手册),

如果我们按照自己的习惯来写的话,可能有些地方不太全面或者不够规范,不太好看等等。

为此为了寻找一个适合自己的编写规范以及国际化,我们需要去阅读别人的编写方法及规范。

我们来看下

1.CHANGELOG-hdck解读

hdck写的版本变更文件 ,文件名叫做CHANGELOG,也就是改变日志的意思。

HDCK是一个测试硬盘的检测工具,主要再Linux操作系统,编译运行。它可以检测出每个块的质量,是好的还是不好的,最后有一个对硬盘的评估,在我看来,这个软件非常棒。

我们来看看里面的内容

CHANGELOG

v 0.5.0 - 2011-02-06
--------------------* add support for ATA VERIFY command to allow testing drives over USB, FireWire and behind SAS backplanes* fix crash with specific sized drivesv 0.4.0 - 2010-10-07
--------------------* change to quantile based detection* fix a bug in with min-reads == max-reads* tweaks to quick mode -- confirm only the 64 worst* fix bug with long options --log, --read-sectors and --bad-sectors not working* reduced CPU utilisationv 0.3.0 - 2010-08-25
--------------------* reduce number of global variables* quick mode* more verbose on-line status reporting* printing 10 worst (slowest) blocks in resultstd dev, min, max, avg, truncated avg, no of samplesv 0.2.6 - 2010-08-22
--------------------* fix printing of Individual block statisticsv 0.2.5 - 2010-08-22
--------------------* compare block times to fractions and multiples of rotational delay, not fixed values* print simple diagnosis (disk condition)* printing status message on multiple lines and on stdout, not stderr* log outputv 0.2.4 - 2010-08-11
--------------------* make output more human readable* fix the problem with maximum number of block reads being min-reads + max-readsv 0.2.3 - 2010-08-11
--------------------* reduce number of unnecessery re-reads* add licences to filesv 0.2.2 - 2010-04-10
--------------------* bugfix -- fix overreading re-read blocks* make the program 64 bit compatible (not tested!)v 0.2.1 - 2010-04-09
--------------------* bugfix -- not rereading blocks that need rereading* code clean up -- removed dead codev 0.2 - 2010-04-08
------------------* reading and writing uncertian block ranges to file* writing detailed statistics to file* `background' mode -- lower priority and less confidence for the results* works with single whole disk read, rereads only sectors that are muchslower than the neighbours* uses disk RPM for detecting blocks that are consistently reread by the disk* on rereads reads disk cache worth of sectors before the scoring blocks toimprove quality of the results

我们可以看到,版本更新都是从下往上更新,也就是说,最上方是最新的版本及更新操作说明,最下方是最低的版本及说明。这样在打开文件的时候就可以清楚地看到最新版本是多少,而且可以看到日期的多小,什么时候写的。在版本日期下面用横线分割,并空了一行,这样可以将上面版本和下方的操作区分开来。而再更改操作说明的每一项的前面空了一格,并且利用星号标注上,让看到文档的人很快的区分开有几项更改以及更改项的内容,除了利用星号标注外,这里我们可以使用数字标注,更加清楚的看到更改了几项。在写更改操作项时尽量做到简洁明了,让看这个文档的人可以理解更改了什么东西。

 

2.CHANGELOG-Oprofile解读

接下来我们看一下oprofile

oprofile是Linux上的性能检测工具,通过CPU硬件提供的性能计数器对事件进行采样,从代码层面分析程序的性能消耗情况,找到程序性能的问题点。

 

oprofile的变更日志是这样写的

它将日志按照年份分成好几份,写法如下

ChangeLog-2002 、ChangeLog-2003 ...... ChangeLog-2011

我们看一下ChangeLog-2010这个文件

2010-12-16  John Villalovos <john.l.villalovos@intel.com>* events/Makefile.am:* libop/op_cpu_type.c:* libop/op_cpu_type.h:* libop/op_hw_specific.h:* libop/op_events.c:* utils/ophelp.c:* events/i386/westmere/events (new):* events/i386/westmere/unit_masks (new): Add support for IntelWestmere micro-architecture processors2010-12-15  Will Cohen  <wcohen@redhat.com>* libop/op_cpu_type.c:* libop/op_cpu_type.h:* libop/op_hw_specific.h: User-space identification of processorsthat support Intel architectural events2010-12-14  Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>* oprofile/daemon/opd_ibs_trans.c: Fix non-x86 build issue due to cpuid instruction2010-10-15  Roland Grunberg  <roland.grunberg@gmail.com>* libop/op_xml_events.c:* libop/op_xml_out.c:* libop/op_xml_out.h:* doc/ophelp.xsd: Add unit mask type attribute for an event inthe ophelp schema2010-10-15  Maynard Johnson  <maynardj@us.ibm.com>* doc/ophelp.xsd:* libop/op_xml_events.c: Fix schema validation issues and error inxml generation2010-10-13  Maynard Johnson  <maynardj@us.ibm.com>* libabi/opimport.cpp: Fix uninitialized variable warning whenbuilding with gcc 4.42010-10-13  Maynard Johnson  <maynardj@us.ibm.com>* events/mips/Makefile.am: Correction to 8/26 MIPS patchto add events and unit_masks to makefile2010-10-07  William Cohen  <wcohen@redhat.com>* events/i386/arch_perfmon/events: Correct filter values.2010-08-02  Maynard Johnson  <maynardj@us.ibm.com>* utils/opcontrol:* libpp/profile_spec.cpp:* pp/oparchive.cpp:  Moved the copying of stats to opcontrol::do_dump_dataand removed the unnecessary and confusing message that indicatedwhen overflow stats were not available.2010-06-11  William Cohen <wcohen@redhat.com>* libregex/stl.pat.in: Avoid machine specific configuration.2010-05-18  Daniel Hansel  <daniel.hansel@linux.vnet.ibm.com>* doc/oprofile.xml: Document that only kernel versions 2.6.13 orlater provide support for anonymous mapped regions2010-04-13  Maynard Johnson  <maynardj@us.ibm.com>* libutil++/bfd_support.cpp: Fix up translate_debuginfo_symsso it doesn't rely on section index values being the samebetween real image and debuginfo file (to resolve problemreported by Will Cohen on Fedora 12)2010-03-25  Oliver Schneider  <oliver@assarbad.net>* libpp/parse_filename.cpp:  Catch case where a basic_string::eraseerror can occur in opreport when parsing an invalid sample file name2010-03-25  Maynard Johnson  <maynardj@us.ibm.com>* events/mips/loongson2/events: New File* events/mips/loongson2/unit_masks: New FileI neglected to do 'cvs add' for these new two new filesback on Nov 25, 2009 when I committed the initialloongson2 support.  This change corrects that error.2010-03-01  Gabor Loki  <loki@inf.u-szeged.hu>* daemon/opd_pipe.c: Fix memory leak* utils/opcontrol: Fix messages sending method to opd_pipe2010-01-20  Maynard Johnson  <maynardj@us.ibm.com>* m4/qt.m4: Fix qt lib check so it works on base 64-bit systemSee ChangeLog-2009 for earlier changelogs.

我们可以看到和第一个一样,版本都是从下往上写,在最下方有个查看2009年的变更说明。这个写法很好,因为它这里面分成了各个年的变更日志。中间的版本变更与第一个不一样,这个里面没有版本号,但是有变更日期,以及变更人和邮箱,这个加了个变更人和邮箱,就可以明确的看到这个变更代码的人是谁,假如代码除了问题,可以通过邮箱去联系编写这个代码的人,这个写法很好的。值得提倡。操作变更说明和第一个也是一样。在每个变更项前方添加空格和星号。

 

 

介绍了两个变更说明文档,下面我们来看看README文件别人是怎么写的

3.README-FIO解读

fio是Linux对硬盘进行io测试的一个主流的工具

 

FIO的README文件

Overview and history
--------------------Fio was originally written to save me the hassle of writing special test case
programs when I wanted to test a specific workload, either for performance
reasons or to find/reproduce a bug. The process of writing such a test app can
be tiresome, especially if you have to do it often.  Hence I needed a tool that
would be able to simulate a given I/O workload without resorting to writing a
tailored test case again and again.A test work load is difficult to define, though. There can be any number of
processes or threads involved, and they can each be using their own way of
generating I/O. You could have someone dirtying large amounts of memory in an
memory mapped file, or maybe several threads issuing reads using asynchronous
I/O. fio needed to be flexible enough to simulate both of these cases, and many
more.Fio spawns a number of threads or processes doing a particular type of I/O
action as specified by the user. fio takes a number of global parameters, each
inherited by the thread unless otherwise parameters given to them overriding
that setting is given.  The typical use of fio is to write a job file matching
the I/O load one wants to simulate.Source
------Fio resides in a git repo, the canonical place is:git://git.kernel.dk/fio.gitWhen inside a corporate firewall, git:// URL sometimes does not work.
If git:// does not work, use the http protocol instead:http://git.kernel.dk/fio.gitSnapshots are frequently generated and :file:`fio-git-*.tar.gz` include the git
meta data as well. Other tarballs are archives of official fio releases.
Snapshots can download from:http://brick.kernel.dk/snaps/There are also two official mirrors. Both of these are automatically synced with
the main repository, when changes are pushed. If the main repo is down for some
reason, either one of these is safe to use as a backup:git://git.kernel.org/pub/scm/linux/kernel/git/axboe/fio.githttps://git.kernel.org/pub/scm/linux/kernel/git/axboe/fio.gitorgit://github.com/axboe/fio.githttps://github.com/axboe/fio.gitMailing list
------------The fio project mailing list is meant for anything related to fio including
general discussion, bug reporting, questions, and development. For bug reporting,
see REPORTING-BUGS.An automated mail detailing recent commits is automatically sent to the list at
most daily. The list address is fio@vger.kernel.org, subscribe by sending an
email to majordomo@vger.kernel.org withsubscribe fioin the body of the email. Archives can be found here:http://www.spinics.net/lists/fio/and archives for the old list can be found here:http://maillist.kernel.dk/fio-devel/Author
------Fio was written by Jens Axboe <axboe@kernel.dk> to enable flexible testing of
the Linux I/O subsystem and schedulers. He got tired of writing specific test
applications to simulate a given workload, and found that the existing I/O
benchmark/test tools out there weren't flexible enough to do what he wanted.Jens Axboe <axboe@kernel.dk> 20060905Binary packages
---------------Debian:Starting with Debian "Squeeze", fio packages are part of the officialDebian repository. http://packages.debian.org/search?keywords=fio .Ubuntu:Starting with Ubuntu 10.04 LTS (aka "Lucid Lynx"), fio packages are partof the Ubuntu "universe" repository.http://packages.ubuntu.com/search?keywords=fio .Red Hat, Fedora, CentOS & Co:Starting with Fedora 9/Extra Packages for Enterprise Linux 4, fiopackages are part of the Fedora/EPEL repositories.https://apps.fedoraproject.org/packages/fio .Mandriva:Mandriva has integrated fio into their package repository, so installingon that distro should be as easy as typing ``urpmi fio``.Arch Linux:An Arch Linux package is provided under the Community sub-repository:https://www.archlinux.org/packages/?sort=&q=fioSolaris:Packages for Solaris are available from OpenCSW. Install their pkgutiltool (http://www.opencsw.org/get-it/pkgutil/) and then install fio via``pkgutil -i fio``.Windows:Rebecca Cran <rebecca@bsdio.com> has fio packages for Windows athttps://bsdio.com/fio/ . The latest builds for Windows can alsobe grabbed from https://ci.appveyor.com/project/axboe/fio by clickingthe latest x86 or x64 build, then selecting the ARTIFACTS tab.BSDs:Packages for BSDs may be available from their binary package repositories.Look for a package "fio" using their binary package managers.Building
--------Just type::$ ./configure$ make$ make installNote that GNU make is required. On BSDs it's available from devel/gmake within
ports directory; on Solaris it's in the SUNWgmake package.  On platforms where
GNU make isn't the default, type ``gmake`` instead of ``make``.Configure will print the enabled options. Note that on Linux based platforms,
the libaio development packages must be installed to use the libaio
engine. Depending on distro, it is usually called libaio-devel or libaio-dev.For gfio, gtk 2.18 (or newer), associated glib threads, and cairo are required
to be installed.  gfio isn't built automatically and can be enabled with a
``--enable-gfio`` option to configure.To build fio with a cross-compiler::$ make clean$ make CROSS_COMPILE=/path/to/toolchain/prefixConfigure will attempt to determine the target platform automatically.It's possible to build fio for ESX as well, use the ``--esx`` switch to
configure.Windows
~~~~~~~On Windows, Cygwin (https://www.cygwin.com/) is required in order to build
fio. To create an MSI installer package install WiX from
https://wixtoolset.org and run :file:`dobuild.cmd` from the :file:`os/windows`
directory.How to compile fio on 64-bit Windows:1. Install Cygwin (http://www.cygwin.com/). Install **make** and allpackages starting with **mingw64-x86_64**. Ensure**mingw64-x86_64-zlib** are installed if you wishto enable fio's log compression functionality.2. Open the Cygwin Terminal.3. Go to the fio directory (source files).4. Run ``make clean && make -j``.To build fio for 32-bit Windows, ensure the -i686 versions of the previously
mentioned -x86_64 packages are installed and run ``./configure
--build-32bit-win`` before ``make``. To build an fio that supports versions of
Windows below Windows 7/Windows Server 2008 R2 also add ``--target-win-ver=xp``
to the end of the configure line that you run before doing ``make``.It's recommended that once built or installed, fio be run in a Command Prompt or
other 'native' console such as console2, since there are known to be display and
signal issues when running it under a Cygwin shell (see
https://github.com/mintty/mintty/issues/56 and
https://github.com/mintty/mintty/wiki/Tips#inputoutput-interaction-with-alien-programs
for details).Documentation
~~~~~~~~~~~~~Fio uses Sphinx_ to generate documentation from the reStructuredText_ files.
To build HTML formatted documentation run ``make -C doc html`` and direct your
browser to :file:`./doc/output/html/index.html`.  To build manual page run
``make -C doc man`` and then ``man doc/output/man/fio.1``.  To see what other
output formats are supported run ``make -C doc help``... _reStructuredText: http://www.sphinx-doc.org/rest.html
.. _Sphinx: http://www.sphinx-doc.orgPlatforms
---------Fio works on (at least) Linux, Solaris, AIX, HP-UX, OSX, NetBSD, OpenBSD,
Windows, FreeBSD, and DragonFly. Some features and/or options may only be
available on some of the platforms, typically because those features only apply
to that platform (like the solarisaio engine, or the splice engine on Linux).Some features are not available on FreeBSD/Solaris even if they could be
implemented, I'd be happy to take patches for that. An example of that is disk
utility statistics and (I think) huge page support, support for that does exist
in FreeBSD/Solaris.Fio uses pthread mutexes for signalling and locking and some platforms do not
support process shared pthread mutexes. As a result, on such platforms only
threads are supported. This could be fixed with sysv ipc locking or other
locking alternatives.Other \*BSD platforms are untested, but fio should work there almost out of the
box. Since I don't do test runs or even compiles on those platforms, your
mileage may vary. Sending me patches for other platforms is greatly
appreciated. There's a lot of value in having the same test/benchmark tool
available on all platforms.Note that POSIX aio is not enabled by default on AIX. Messages like these::Symbol resolution failed for /usr/lib/libc.a(posix_aio.o) because:Symbol _posix_kaio_rdwr (number 2) is not exported from dependent module /unix.indicate one needs to enable POSIX aio. Run the following commands as root::# lsdev -C -l posix_aio0posix_aio0 Defined  Posix Asynchronous I/O# cfgmgr -l posix_aio0# lsdev -C -l posix_aio0posix_aio0 Available  Posix Asynchronous I/OPOSIX aio should work now. To make the change permanent::# chdev -l posix_aio0 -P -a autoconfig='available'posix_aio0 changedRunning fio
-----------Running fio is normally the easiest part - you just give it the job file
(or job files) as parameters::$ fio [options] [jobfile] ...and it will start doing what the *jobfile* tells it to do. You can give more
than one job file on the command line, fio will serialize the running of those
files. Internally that is the same as using the :option:`stonewall` parameter
described in the parameter section.If the job file contains only one job, you may as well just give the parameters
on the command line. The command line parameters are identical to the job
parameters, with a few extra that control global parameters.  For example, for
the job file parameter :option:`iodepth=2 <iodepth>`, the mirror command line
option would be :option:`--iodepth 2 <iodepth>` or :option:`--iodepth=2
<iodepth>`. You can also use the command line for giving more than one job
entry. For each :option:`--name <name>` option that fio sees, it will start a
new job with that name.  Command line entries following a
:option:`--name <name>` entry will apply to that job, until there are no more
entries or a new :option:`--name <name>` entry is seen. This is similar to the
job file options, where each option applies to the current job until a new []
job entry is seen.fio does not need to run as root, except if the files or devices specified in
the job section requires that. Some other options may also be restricted, such
as memory locking, I/O scheduler switching, and decreasing the nice value.If *jobfile* is specified as ``-``, the job file will be read from standard
input.

从这个README文件,我们可以看到它分成了10项,1. <Overview and history> 前言和历史2.<Source> 源码  3.<Mailing list> 邮件列表 4.<Author>作者 5.<Binary packages>二进制包 6.<Building>编译  7.<Windows> 8.<Documentation>文档 9.<Platforms>平台 10.<Running fio>运行fio

这个fio的README写的还是比较详细的。

 

4.README-Oprofile解读

我们再来看看oprofile的README文件

OProfile provides a low-overhead profiler (operf) capable of both
single-application profiling and system-wide profiling.  There is
also a simple event counting tool (ocount).You can find some documentation in the doc/ directory.Please visit the oprofile website at : http://oprofile.sf.net/oprofile was originally written by John Levon <levon@movementarian.org>
and Philippe Elie <phil.el@wanadoo.fr>.  The operf and ocount
tools were developed by Maynard Johnson <maynardj@us.ibm.com>, who
is the current maintainer.Dave Jones <davej@suse.de> provided bug fixes and support for
the AMD Athlon, and AMD Hammer families of CPUs. Suravee.Suthikulpanit@amd.com
<Suravee.Suthikulpanit@amd.com> contributed various AMD-related patches,
including Instruction-Based-Sampling support (available only in
pre-1.0 releases).Bob Montgomery <bobm@fc.hp.com> provided bug fixes, the initial RTC
driver and the initial ia64 driver.Will Cohen <wcohen@redhat.com> integrated the ia64 driver into the
oprofile release, and contributed bug fixes and several cleanups.Will Deacon <will.deacon@arm.com> has contributed patches as well as
his time to support the ARM architecture.Graydon Hoare <graydon@redhat.com> provided P4 port, bug fixes and cleanups.Ralf Baechle <ralf@linux-mips.org> provided the MIPS port.Other contributors can be seen via 'git log'.Building
--------Please read the installation instructions in doc/oprofile.html or
http://oprofile.sourceforge.net/doc/install.html.
Only 2.6 kernels (or later) are supported.Quick start :(If using git: ./autogen.sh first. You need automake 1.5 or higher. You
can specify a different version, e.g.
ACLOCAL=aclocal-1.5 AUTOMAKE=automake-1.5 AUTOCONF=autoconf-2.13 AUTOHEADER=autoheader-2.13 ./autogen.sh)Then run the following commands./configure [options]  (use './configure --help' to see options)make

oprofile的README文档就没有fio的README文档写的详细了。

 

 

大家可以看看他们的写法写自己的文档吧,谢谢!

  相关解决方案