bug 472706 - add better profiling input for spidermonkey in PGO builds. r=ted

--HG--
rename : modules/libpr0n/test/unit/image3.ico => build/pgo/favicon.ico
This commit is contained in:
Robert Sayre 2009-01-13 07:34:19 -05:00
Родитель b4b15a8e1f
Коммит 7ddcc5ccea
52 изменённых файлов: 10164 добавлений и 167 удалений

Просмотреть файл

@ -82,6 +82,8 @@ if __name__ == '__main__':
browserEnv["MOZILLA_FIVE_HOME"] = os.path.join(SCRIPT_DIR, DIST_BIN)
browserEnv["GNOME_DISABLE_CRASH_DIALOG"] = "1"
automation.runApp("http://localhost:%d/bloatcycle.html" % PORT, browserEnv,
os.path.join(SCRIPT_DIR, automation.DEFAULT_APP),
PROFILE_DIRECTORY, extraArgs)
url = "http://localhost:%d/bloatcycle.html" % PORT
appPath = os.path.join(SCRIPT_DIR, automation.DEFAULT_APP)
(status, start) = automation.runApp(url, browserEnv, appPath,
PROFILE_DIRECTORY, extraArgs)
sys.exit(status)

Просмотреть файл

@ -45,8 +45,10 @@ relativesrcdir = build/pgo
include $(DEPTH)/config/autoconf.mk
DIRS = \
certs \
$(NULL)
blueprint \
js-input \
certs \
$(NULL)
include $(topsrcdir)/config/rules.mk
@ -56,13 +58,13 @@ _CERTS_DIR = $(_PROFILE_DIR)/certs
_CERTS_SRC_DIR = $(srcdir)/certs
_PGO_FILES = \
automation.py \
profileserver.py \
genpgocert.py \
index.html \
quit.js \
server-locations.txt \
$(NULL)
automation.py \
profileserver.py \
genpgocert.py \
index.html \
server-locations.txt \
favicon.ico \
$(NULL)
ifeq ($(USE_SHORT_LIBNAME), 1)
PROGRAM = $(MOZ_APP_NAME)$(BIN_SUFFIX)

Просмотреть файл

@ -445,6 +445,7 @@ def environment(env = None):
###############
def runApp(testURL, env, app, profileDir, extraArgs):
"Run the app, returning a tuple containing the status code and the time at which it was started."
if (IS_TEST_BUILD):
# create certificate database for the profile
certificateStatus = fillCertificateDB(profileDir)
@ -491,4 +492,4 @@ def runApp(testURL, env, app, profileDir, extraArgs):
if (IS_TEST_BUILD):
ssltunnelProcess.kill()
return start
return (status, start)

314
build/pgo/blueprint/LICENSE Normal file
Просмотреть файл

@ -0,0 +1,314 @@
Blueprint CSS Framework License
----------------------------------------------------------------
Copyright (c) 2007-2008 Olav Bjorkoy (olav at bjorkoy.com)
The Blueprint CSS Framework is available for use in all personal or
commercial projects, under both the (modified) MIT and the GPL license. You
may choose the one that fits your project.
The (modified) MIT License
----------------------------------------------------------------
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sub-license, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice, and every other copyright notice found in this
software, and all the attributions in every file, and this permission notice
shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
The GPL License
----------------------------------------------------------------
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

Просмотреть файл

@ -0,0 +1,63 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla PGO Input.
#
# The Initial Developer of the Original Code is
# The Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2008
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Robert Sayre <sayrer@gmail.com>
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_PROFILE_DIR = $(DEPTH)/_profile/pgo/blueprint
_PGO_FILES = \
sample.html \
elements.html \
forms.html \
grid.html \
test.jpg \
test-small.jpg \
valid.png \
screen.css \
print.css \
grid.png \
fancytype-screen.css \
$(NULL)
libs:: $(_PGO_FILES)
$(INSTALL) $^ $(_PROFILE_DIR)

Просмотреть файл

@ -0,0 +1,246 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Blueprint HTML Elements Tests</title>
<!-- Framework CSS -->
<link rel="stylesheet" href="screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="print.css" type="text/css" media="print">
<!--[if IE]><link rel="stylesheet" href="ie.css" type="text/css" media="screen, projection"><![endif]-->
</head>
<body>
<div class="container showgrid">
<h2>Tests for common HTML elements</h2>
<hr>
<h5>PARAGRAPHS <span class="alt">&amp;</span> BOXES</h5>
<div class="span-8">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor <sub>sub text</sub> ut labore et <sup>sup text</sup> magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="span-8">
<p class="small">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="large">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div class="span-8 last">
<div class="box">
<p class="last">Aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</blockquote>
</div>
<hr>
<h5>LISTS</h5>
<div class="span-8">
<ul>
<li>Unordered list test</li>
<li>Another list element. Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
<li>Yet another element in the list</li>
<li>Some long text. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
</ul>
<ol>
<li>Ordered list test</li>
<li>Another list element</li>
<li>Yet another element in the list</li>
</ol>
</div>
<div class="span-8">
<ol>
<li>Ordered list</li>
<li>Here's a nested unordered list
<ul>
<li>Nested Unordered list</li>
<li>Nested ordered list
<ol>
<li>The first</li>
<li>And the second</li>
</ol>
</li>
</ul>
</li>
<li>Ordered List item</li>
<li>Nested Ordered list
<ol>
<li>Some point</li>
<li>Nested Unordered list
<ul>
<li>The first</li>
<li>And the second</li>
</ul>
</li>
</ol>
</li>
</ol>
</div>
<div class="span-8 last">
<dl>
<dt>definition list dt</dt>
<dd>definition list dd</dd>
<dt>definition list dt</dt>
<dd>definition list dd</dd>
<dt>Lorem ipsum dolor sit amet, consectetur adipisicing elit adipisicing elit adipisicing elit</dt>
<dd>Lorem ipsum dolor sit amet, consectetur adipisicing elit adipisicing elit adipisicing elit</dd>
<dt>Lorem ipsum dolor sit amet, consectetur adipisicing elit adipisicing elit adipisicing elit</dt>
<dd>Lorem ipsum dolor sit amet, consectetur adipisicing elit adipisicing elit adipisicing elit</dd>
</dl>
</div>
<hr>
<h5>HEADINGS</h5>
<div class="span-8">
<h1>H1: Lorem ipsum dolor sit amet</h1>
<h2>H2: Lorem ipsum dolor sit amet, consectetur elit</h2>
<h3>H3: Lorem ipsum dolor sit amet, consectetur adipisicing elit</h3>
<h4>H4: Lorem ipsum dolor sit amet, consectetur adipisicing elit adipis</h4>
<h5>H5: Lorem ipsum dolor sit amet, consectetur adipisicing elit adipisicing elit adipisicing elit</h5>
<h6>H6: Lorem ipsum dolor sit amet, consectetur adipisicing elit adipisicing elit adipisicing elit</h6>
</div>
<div class="span-8">
<h1>Heading 1</h1><hr>
<h2>Heading 2</h2><hr>
<h3>Heading 3</h3><hr>
<h4>Heading 4</h4><hr>
<h5>Heading 5</h5><hr>
<h6>Heading 6</h6>
</div>
<div class="span-8 last">
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
</div>
<hr>
<h5>MISC ELEMENTS</h5>
<div class="span-8">
<p>
<strong>&lt;strong&gt;</strong><br>
<del>&lt;del&gt; deleted</del><br>
<dfn>&lt;dfn&gt; dfn</dfn><br>
<em>&lt;em&gt; emphasis</em>
</p>
<p>
<a>&lt;a&gt; anchor</a><br>
<a href="http://www.google.com">&lt;a&gt; a + href</a>
</p>
<p>
<abbr title="extended abbr text should show when mouse over">&lt;abbr&gt; abbr - extended text when mouseover.</abbr><br>
<acronym title="extended acronym text should show when mouse over">&lt;acronym&gt; acronym - extended text when mouseover.</acronym>
</p>
<address>
&lt;address&gt;<br>
Donald Duck<br>
Box 555<br>
Disneyland
</address>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore dolore.</p>
</div>
<div class="span-8">
<table summary="This is the summary text for this table." border="0" cellspacing="0" cellpadding="0">
<caption><em>A standard test table with a caption, tr, td elements</em></caption>
<tr>
<th class="span-4">Table Header One</th>
<th class="span-4 last">Table Header Two</th>
</tr>
<tr>
<td>TD One</td>
<td>TD Two</td>
</tr>
<tr>
<td colspan="2">TD colspan 2</td>
</tr>
</table>
<table summary="This is the summary text for this table." border="0" cellspacing="0" cellpadding="0">
<caption><em>A test table with a thead, tfoot, and tbody elements</em></caption>
<thead>
<tr>
<th class="span-4">Table Header One</th>
<th class="span-4 last">Table Header Two</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="2">tfoot footer</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>TD One</td>
<td>TD Two</td>
</tr>
<tr>
<td>TD One</td>
<td>TD Two</td>
</tr>
</tbody>
<tbody>
<tr>
<td>TD One</td>
<td>TD Two</td>
</tr>
<tr>
<td>TD One</td>
<td>TD Two</td>
</tr>
</tbody>
</table>
</div>
<div class="span-8 last">
<pre>&lt;pre&gt;
pre space1
pre space1
pre space2
pre space2
pre tab
pre tab</pre>
<code>&lt;code&gt;
Not indented
indent1
indent1
indent2
indent3</code>
<tt>&lt;tt&gt;
This tt text should be monospaced
and
wrap as if
one line of text
even though the code has newlines, spaces, and tabs.
It should be the same size as &lt;p&gt; text.
</tt>
</div>
<hr>
<p><a href="http://validator.w3.org/check?uri=referer">
<img src="valid.png" alt="Valid HTML 4.01 Strict" height="31" width="88" class="top"></a></p>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,71 @@
/* --------------------------------------------------------------
fancy-type.css
* Lots of pretty advanced classes for manipulating text.
See the Readme file in this folder for additional instructions.
-------------------------------------------------------------- */
/* Indentation instead of line shifts for sibling paragraphs. */
p + p { text-indent:2em; margin-top:-1.5em; }
form p + p { text-indent: 0; } /* Don't want this in forms. */
/* For great looking type, use this code instead of asdf:
<span class="alt">asdf</span>
Best used on prepositions and ampersands. */
.alt {
color: #666;
font-family: "Warnock Pro", "Goudy Old Style","Palatino","Book Antiqua", Georgia, serif;
font-style: italic;
font-weight: normal;
}
/* For great looking quote marks in titles, replace "asdf" with:
<span class="dquo">&#8220;</span>asdf&#8221;
(That is, when the title starts with a quote mark).
(You may have to change this value depending on your font size). */
.dquo { margin-left: -.5em; }
/* Reduced size type with incremental leading
(http://www.markboulton.co.uk/journal/comments/incremental_leading/)
This could be used for side notes. For smaller type, you don't necessarily want to
follow the 1.5x vertical rhythm -- the line-height is too much.
Using this class, it reduces your font size and line-height so that for
every four lines of normal sized type, there is five lines of the sidenote. eg:
New type size in em's:
10px (wanted side note size) / 12px (existing base size) = 0.8333 (new type size in ems)
New line-height value:
12px x 1.5 = 18px (old line-height)
18px x 4 = 72px
72px / 5 = 14.4px (new line height)
14.4px / 10px = 1.44 (new line height in em's) */
p.incr, .incr p {
font-size: 10px;
line-height: 1.44em;
margin-bottom: 1.5em;
}
/* Surround uppercase words and abbreviations with this class.
Based on work by Jørgen Arnor Gårdsø Lom [http://twistedintellect.com/] */
.caps {
font-variant: small-caps;
letter-spacing: 1px;
text-transform: lowercase;
font-size:1.2em;
line-height:1%;
font-weight:bold;
padding:0 2px;
}

Просмотреть файл

@ -0,0 +1,100 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Blueprint Forms Tests</title>
<!-- Framework CSS -->
<link rel="stylesheet" href="screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="print.css" type="text/css" media="print">
<!--[if IE]><link rel="stylesheet" href="ie.css" type="text/css" media="screen, projection"><![endif]-->
</head>
<body>
<div class="container showgrid">
<h1>Forms</h1>
<hr>
<div class="span-12">
<form id="dummy" action="" method="post">
<fieldset>
<legend>Simple sample form</legend>
<p><label for="dummy0">Text input (title)</label><br>
<input type="text" class="title" name="dummy0" id="dummy0" value="Field with class .title"></p>
<p><label for="dummy1">Another field</label><br>
<input type="text" class="text" id="dummy1" name="dummy1" value="Field with class .text"></p>
<p><label for="dummy2">Textarea</label><br>
<textarea name="dummy2" id="dummy2" rows="5" cols="20"></textarea></p>
<p><input type="submit" value="Submit">
<input type="reset" value="Reset"></p>
</fieldset>
</form>
</div>
<div class="span-12 last">
<div class="error">
This is a &lt;div&gt; with the class <strong>.error</strong>. <a href="#">Link</a>.
</div>
<div class="notice">
This is a &lt;div&gt; with the class <strong>.notice</strong>. <a href="#">Link</a>.
</div>
<div class="success">
This is a &lt;div&gt; with the class <strong>.success</strong>. <a href="#">Link</a>.
</div>
<fieldset>
<legend>Select, checkboxes, lists</legend>
<p><label for="dummy3">Select field</label><br>
<select id="dummy3" name="dummy3">
<option value="1">Ottawa</option>
<option value="2">Calgary</option>
<option value="3">Moosejaw</option>
</select></p>
<p><label for="dummy4">Select with groups</label><br>
<select id="dummy4" name="dummy4">
<option>Favorite pet</option>
<optgroup label="mammals">
<option>dog</option>
<option>cat</option>
<option>rabbit</option>
<option>horse</option>
</optgroup>
<optgroup label="reptiles">
<option>iguana</option>
<option>snake</option>
</optgroup>
</select></p>
<p><label>Radio buttons</label><br>
<input type="radio" name="example"> Radio one<br>
<input type="radio" name="example"> Radio two<br>
<input type="radio" name="example"> Radio three<br></p>
<p><label>Checkboxes</label><br>
<input type="checkbox"> Check one<br>
<input type="checkbox"> Check two<br>
<input type="checkbox"> Check three<br></p>
</fieldset>
</div>
<hr>
<p><a href="http://validator.w3.org/check?uri=referer">
<img src="valid.png" alt="Valid HTML 4.01 Strict" height="31" width="88" class="top"></a></p>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,206 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Blueprint Grid Tests</title>
<!-- Framework CSS -->
<link rel="stylesheet" href="screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="print.css" type="text/css" media="print">
<!--[if IE]><link rel="stylesheet" href="ie.css" type="text/css" media="screen, projection"><![endif]-->
</head>
<body>
<div class="container showgrid">
<h1>Blueprint Tests: grid.css</h1>
<div class="span-8">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
<div class="span-8">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
<div class="span-8 last">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
<div class="span-6 append-1">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
<div class="span-6 append-2">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
<div class="span-6 append-3 last">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
<div class="span-6 prepend-1">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
<div class="span-6 prepend-2">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
<div class="span-6 prepend-3 last">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
<hr>
<div class="span-12 border">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="span-12 last">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<hr>
<div class="span-1 prepend-1"><p>1</p></div>
<div class="span-1 prepend-2"><p>2</p></div>
<div class="span-1 prepend-3"><p>3</p></div>
<div class="span-1 prepend-4"><p>4</p></div>
<div class="span-1 prepend-5"><p>5</p></div>
<div class="span-1 prepend-3 last"><p>3</p></div>
<div class="span-1 append-1"><p>1</p></div>
<div class="span-1 append-2"><p>2</p></div>
<div class="span-1 append-3"><p>3</p></div>
<div class="span-1 append-4"><p>4</p></div>
<div class="span-1 append-5"><p>5</p></div>
<div class="span-1 append-3 last"><p>3</p></div>
<div class="span-1 border"><p>1</p></div>
<div class="span-1 border"><p>2</p></div>
<div class="span-1 border"><p>3</p></div>
<div class="span-1 border"><p>4</p></div>
<div class="span-1 border"><p>5</p></div>
<div class="span-1 border"><p>6</p></div>
<div class="span-1 border"><p>7</p></div>
<div class="span-1 border"><p>8</p></div>
<div class="span-1 border"><p>9</p></div>
<div class="span-1 border"><p>10</p></div>
<div class="span-1 border"><p>11</p></div>
<div class="span-1 border"><p>12</p></div>
<div class="span-1 border"><p>13</p></div>
<div class="span-1 border"><p>14</p></div>
<div class="span-1 border"><p>15</p></div>
<div class="span-1 border"><p>16</p></div>
<div class="span-1 border"><p>17</p></div>
<div class="span-1 border"><p>18</p></div>
<div class="span-1 border"><p>19</p></div>
<div class="span-1 border"><p>20</p></div>
<div class="span-1 border"><p>21</p></div>
<div class="span-1 border"><p>22</p></div>
<div class="span-1 border"><p>23</p></div>
<div class="span-1 last"><p>24</p></div>
<div class="span-4"><p>1</p></div>
<div class="span-4"><p>2</p></div>
<div class="span-4"><p>3</p></div>
<div class="span-4"><p>4</p></div>
<div class="span-4"><p>5</p></div>
<div class="span-4 last"><p>6</p></div>
<div class="prepend-23 span-1 last"><p>24</p></div>
<div class="prepend-1 span-1"><p>2</p></div>
<div class="prepend-20 span-1 append-1 last"><p>23</p></div>
<hr>
<div class="span-24">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="span-12">
<div class="span-6">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.</p>
</div>
<div class="span-6 last">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div class="span-12 last">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
<div class="span-12 last">
<div class="span-6">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.</p>
</div>
<div class="span-6 last">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div class="span-12 last">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
<div class="span-14 prepend-5 append-5 last">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<hr>
<div class="span-12">
<h5>TESTING .PUSH-1 TO .PUSH-5</h5>
<div class="span-2"><img src="test-small.jpg" class="push-1"></div>
<div class="span-10 last"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></div>
<div class="span-2"><img src="test-small.jpg" class="push-2"></div>
<div class="span-10 last"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></div>
<div class="span-2"><img src="test-small.jpg" class="push-3"></div>
<div class="span-10 last"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></div>
<div class="span-2"><img src="test-small.jpg" class="push-4"></div>
<div class="span-10 last"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></div>
<div class="span-2"><img src="test-small.jpg" class="push-5"></div>
<div class="span-10 last"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></div>
</div>
<div class="span-12 last">
<h5>TESTING .PULL-1 TO .PULL-5</h5>
<div class="span-10"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></div>
<div class="span-2 last"><img src="test-small.jpg" class="top pull-1"></div>
<div class="span-10"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></div>
<div class="span-2 last"><img src="test-small.jpg" class="top pull-2"></div>
<div class="span-10"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></div>
<div class="span-2 last"><img src="test-small.jpg" class="top pull-3"></div>
<div class="span-10"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></div>
<div class="span-2 last"><img src="test-small.jpg" class="top pull-4"></div>
<div class="span-10"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></div>
<div class="span-2 last"><img src="test-small.jpg" class="top pull-5"></div>
</div>
<div class="span-24">
<p><a href="http://validator.w3.org/check?uri=referer">
<img src="valid.png" alt="Valid HTML 4.01 Strict" height="31" width="88" class="bottom"></a></p>
</div>
</div>
</body>
</html>

Двоичные данные
build/pgo/blueprint/grid.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 206 B

Просмотреть файл

@ -0,0 +1,29 @@
/* -----------------------------------------------------------------------
Blueprint CSS Framework 0.7.1
http://blueprintcss.googlecode.com
* Copyright (c) 2007-2008. See LICENSE for more info.
* See README for instructions on how to use Blueprint.
* For credits and origins, see AUTHORS.
* This is a compressed file. See the sources in the 'src' directory.
----------------------------------------------------------------------- */
/* print.css */
body {line-height:1.5;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;color:#000;background:none;font-size:10pt;}
.container {background:none;}
hr {background:#ccc;color:#ccc;width:100%;height:2px;margin:2em 0;padding:0;border:none;}
hr.space {background:#fff;color:#fff;}
h1, h2, h3, h4, h5, h6 {font-family:"Helvetica Neue", Arial, "Lucida Grande", sans-serif;}
code {font:.9em "Courier New", Monaco, Courier, monospace;}
img {float:left;margin:1.5em 1.5em 1.5em 0;}
a img {border:none;}
p img.top {margin-top:0;}
blockquote {margin:1.5em;padding:1em;font-style:italic;font-size:.9em;}
.small {font-size:.9em;}
.large {font-size:1.1em;}
.quiet {color:#999;}
.hide {display:none;}
a:link, a:visited {background:transparent;font-weight:700;text-decoration:underline;}
a:link:after, a:visited:after {content:" (" attr(href) ") ";font-size:90%;}

Просмотреть файл

@ -0,0 +1,87 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Blueprint Sample Page</title>
<!-- Framework CSS -->
<link rel="stylesheet" href="screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="print.css" type="text/css" media="print">
<!--[if IE]><link rel="stylesheet" href="ie.css" type="text/css" media="screen, projection"><![endif]-->
<!-- Import fancy-type plugin for the sample page. -->
<link rel="stylesheet" href="fancytype-screen.css" type="text/css" media="screen, projection">
</head>
<body>
<div class="container">
<h1>A simple sample page</h1>
<hr>
<h2 class="alt">This sample page demonstrates a tiny fraction of what you get with Blueprint.</h2>
<hr>
<div class="span-7 colborder">
<h6>Here's a box</h6>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip.</p>
</div>
<div class="span-8 colborder">
<h6>And another box</h6>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat laboris nisi ut aliquip.</p>
</div>
<div class="span-7 last">
<h6>This box is aligned with the sidebar</h6>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip.</p>
</div>
<hr>
<hr class="space">
<div class="span-15 prepend-1 colborder">
<p><img src="test.jpg" class="top pull-1" alt="test">Lorem ipsum dolor sit amet, <em>consectetuer adipiscing elit</em>. Nunc congue ipsum vestibulum libero. Aenean vitae justo. Nam eget tellus. Etiam convallis, est eu lobortis mattis, lectus tellus tempus felis, a ultricies erat ipsum at metus.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. <a href="#">Morbi et risus</a>. Aliquam nisl. Nulla facilisi. Cras accumsan vestibulum ante. Vestibulum sed tortor. Praesent <span class="caps">SMALL CAPS</span> tempus fringilla elit. Ut elit diam, sagittis in, nonummy in, gravida non, nunc. Ut orci. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nam egestas, orci eu imperdiet malesuada, nisl purus fringilla odio, quis commodo est orci vitae justo. Aliquam placerat odio tincidunt nulla. Cras in libero. Aenean rutrum, magna non tristique posuere, erat odio eleifend nisl, non convallis est tortor blandit ligula. Nulla id augue.</p>
<p>Nullam mattis, odio ut tempus facilisis, metus nisl facilisis metus, auctor consectetuer felis ligula nec mauris. Vestibulum odio erat, fermentum at, commodo vitae, ultrices et, urna. Mauris vulputate, mi pulvinar sagittis condimentum, sem nulla aliquam velit, sed imperdiet mi purus eu magna. Nulla varius metus ut eros. Aenean aliquet magna eget orci. Class aptent taciti sociosqu ad litora.</p>
<p>Vivamus euismod. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Suspendisse vel nibh ut turpis dictum sagittis. Aliquam vel velit a elit auctor sollicitudin. Nam vel dui vel neque lacinia pretium. Quisque nunc erat, venenatis id, volutpat ut, scelerisque sed, diam. Mauris ante. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec mattis. Morbi dignissim sollicitudin libero. Nulla lorem.</p>
<blockquote>
<p>Integer cursus ornare mauris. Praesent nisl arcu, imperdiet eu, ornare id, scelerisque ut, nunc. Praesent sagittis erat sed velit tempus imperdiet. Ut tristique, ante in interdum hendrerit, erat enim faucibus felis, quis rutrum mauris lorem quis sem. Vestibulum ligula nisi, mattis nec, posuere et, blandit eu, ligula. Nam suscipit placerat odio. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Pellentesque tortor libero, venenatis vitae, rhoncus eu, placerat ut, mi. Nulla nulla.</p>
</blockquote>
<p>Maecenas vel metus quis magna pharetra fermentum. <em>Integer sit amet tortor</em>. Maecenas porttitor, pede sed gravida auctor, nulla augue aliquet elit, at pretium urna orci ut metus. Aliquam in dolor. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, tellus id ornare posuere, quam nunc accumsan turpis, at convallis tellus orci et nisl. Phasellus congue neque a lorem.</p>
<hr>
<div class="span-7 colborder">
<h6>This is a nested column</h6>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
</div>
<div class="span-7 last">
<h6>This is another nested column</h6>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
</div>
</div>
<div class="span-7 last">
<h3>A <span class="alt">Simple</span> Sidebar</h3>
<p>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue.</p>
<p>Mauris a lectus. Aliquam erat volutpat. Phasellus ultrices mi a sapien. Nunc rutrum egestas lorem. Duis ac sem sagittis elit tincidunt gravida. Mauris a lectus. Aliquam erat volutpat. Phasellus ultrices mi a sapien. Nunc rutrum egestas lorem. Duis ac sem sagittis elit tincidunt gravida.</p>
<p class="quiet">Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue.</p>
<h5>Incremental leading</h5>
<p class="incr">Vestibulum ante ipsum primis in faucibus orci luctus vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. sed aliquet vehicula, lectus tellus.</p>
<p class="incr">Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue.</p>
</div>
<hr>
<h2 class="alt">You may pick and choose amongst these and many more features, so be bold.</h2>
<hr>
<p><a href="http://validator.w3.org/check?uri=referer">
<img src="valid.png" alt="Valid HTML 4.01 Strict" height="31" width="88" class="top"></a></p>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,226 @@
/* -----------------------------------------------------------------------
Blueprint CSS Framework 0.7.1
http://blueprintcss.googlecode.com
* Copyright (c) 2007-2008. See LICENSE for more info.
* See README for instructions on how to use Blueprint.
* For credits and origins, see AUTHORS.
* This is a compressed file. See the sources in the 'src' directory.
----------------------------------------------------------------------- */
/* reset.css */
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;}
body {line-height:1.5;}
table {border-collapse:separate;border-spacing:0;}
caption, th, td {text-align:left;font-weight:normal;}
table, td, th {vertical-align:middle;}
blockquote:before, blockquote:after, q:before, q:after {content:"";}
blockquote, q {quotes:"" "";}
a img {border:none;}
/* typography.css */
body {font-size:75%;color:#222;background:#fff;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;}
h1, h2, h3, h4, h5, h6 {font-weight:normal;color:#111;}
h1 {font-size:3em;line-height:1;margin-bottom:0.5em;}
h2 {font-size:2em;margin-bottom:0.75em;}
h3 {font-size:1.5em;line-height:1;margin-bottom:1em;}
h4 {font-size:1.2em;line-height:1.25;margin-bottom:1.25em;height:1.25em;}
h5 {font-size:1em;font-weight:bold;margin-bottom:1.5em;}
h6 {font-size:1em;font-weight:bold;}
h1 img, h2 img, h3 img, h4 img, h5 img, h6 img {margin:0;}
p {margin:0 0 1.5em;}
p img {float:left;margin:1.5em 1.5em 1.5em 0;padding:0;}
p img.right {float:right;margin:1.5em 0 1.5em 1.5em;}
a:focus, a:hover {color:#000;}
a {color:#009;text-decoration:underline;}
blockquote {margin:1.5em;color:#666;font-style:italic;}
strong {font-weight:bold;}
em, dfn {font-style:italic;}
dfn {font-weight:bold;}
sup, sub {line-height:0;}
abbr, acronym {border-bottom:1px dotted #666;}
address {margin:0 0 1.5em;font-style:italic;}
del {color:#666;}
pre, code {margin:1.5em 0;white-space:pre;}
pre, code, tt {font:1em 'andale mono', 'lucida console', monospace;line-height:1.5;}
li ul, li ol {margin:0 1.5em;}
ul, ol {margin:0 1.5em 1.5em 1.5em;}
ul {list-style-type:disc;}
ol {list-style-type:decimal;}
dl {margin:0 0 1.5em 0;}
dl dt {font-weight:bold;}
dd {margin-left:1.5em;}
table {margin-bottom:1.4em;width:100%;}
th {font-weight:bold;background:#C3D9FF;}
th, td {padding:4px 10px 4px 5px;}
tr.even td {background:#E5ECF9;}
tfoot {font-style:italic;}
caption {background:#eee;}
.small {font-size:.8em;margin-bottom:1.875em;line-height:1.875em;}
.large {font-size:1.2em;line-height:2.5em;margin-bottom:1.25em;}
.hide {display:none;}
.quiet {color:#666;}
.loud {color:#000;}
.highlight {background:#ff0;}
.added {background:#060;color:#fff;}
.removed {background:#900;color:#fff;}
.first {margin-left:0;padding-left:0;}
.last {margin-right:0;padding-right:0;}
.top {margin-top:0;padding-top:0;}
.bottom {margin-bottom:0;padding-bottom:0;}
/* grid.css */
.container {width:950px;margin:0 auto;}
.showgrid {background:url(grid.png);}
body {margin:1.5em 0;}
div.span-1, div.span-2, div.span-3, div.span-4, div.span-5, div.span-6, div.span-7, div.span-8, div.span-9, div.span-10, div.span-11, div.span-12, div.span-13, div.span-14, div.span-15, div.span-16, div.span-17, div.span-18, div.span-19, div.span-20, div.span-21, div.span-22, div.span-23, div.span-24 {float:left;margin-right:10px;}
div.last {margin-right:0;}
.span-1 {width:30px;}
.span-2 {width:70px;}
.span-3 {width:110px;}
.span-4 {width:150px;}
.span-5 {width:190px;}
.span-6 {width:230px;}
.span-7 {width:270px;}
.span-8 {width:310px;}
.span-9 {width:350px;}
.span-10 {width:390px;}
.span-11 {width:430px;}
.span-12 {width:470px;}
.span-13 {width:510px;}
.span-14 {width:550px;}
.span-15 {width:590px;}
.span-16 {width:630px;}
.span-17 {width:670px;}
.span-18 {width:710px;}
.span-19 {width:750px;}
.span-20 {width:790px;}
.span-21 {width:830px;}
.span-22 {width:870px;}
.span-23 {width:910px;}
.span-24, div.span-24 {width:950px;margin:0;}
.append-1 {padding-right:40px;}
.append-2 {padding-right:80px;}
.append-3 {padding-right:120px;}
.append-4 {padding-right:160px;}
.append-5 {padding-right:200px;}
.append-6 {padding-right:240px;}
.append-7 {padding-right:280px;}
.append-8 {padding-right:320px;}
.append-9 {padding-right:360px;}
.append-10 {padding-right:400px;}
.append-11 {padding-right:440px;}
.append-12 {padding-right:480px;}
.append-13 {padding-right:520px;}
.append-14 {padding-right:560px;}
.append-15 {padding-right:600px;}
.append-16 {padding-right:640px;}
.append-17 {padding-right:680px;}
.append-18 {padding-right:720px;}
.append-19 {padding-right:760px;}
.append-20 {padding-right:800px;}
.append-21 {padding-right:840px;}
.append-22 {padding-right:880px;}
.append-23 {padding-right:920px;}
.prepend-1 {padding-left:40px;}
.prepend-2 {padding-left:80px;}
.prepend-3 {padding-left:120px;}
.prepend-4 {padding-left:160px;}
.prepend-5 {padding-left:200px;}
.prepend-6 {padding-left:240px;}
.prepend-7 {padding-left:280px;}
.prepend-8 {padding-left:320px;}
.prepend-9 {padding-left:360px;}
.prepend-10 {padding-left:400px;}
.prepend-11 {padding-left:440px;}
.prepend-12 {padding-left:480px;}
.prepend-13 {padding-left:520px;}
.prepend-14 {padding-left:560px;}
.prepend-15 {padding-left:600px;}
.prepend-16 {padding-left:640px;}
.prepend-17 {padding-left:680px;}
.prepend-18 {padding-left:720px;}
.prepend-19 {padding-left:760px;}
.prepend-20 {padding-left:800px;}
.prepend-21 {padding-left:840px;}
.prepend-22 {padding-left:880px;}
.prepend-23 {padding-left:920px;}
div.border {padding-right:4px;margin-right:5px;border-right:1px solid #eee;}
div.colborder {padding-right:24px;margin-right:25px;border-right:1px solid #eee;}
.pull-1 {margin-left:-40px;}
.pull-2 {margin-left:-80px;}
.pull-3 {margin-left:-120px;}
.pull-4 {margin-left:-160px;}
.pull-5 {margin-left:-200px;}
.pull-6 {margin-left:-240px;}
.pull-7 {margin-left:-280px;}
.pull-8 {margin-left:-320px;}
.pull-9 {margin-left:-360px;}
.pull-10 {margin-left:-400px;}
.pull-11 {margin-left:-440px;}
.pull-12 {margin-left:-480px;}
.pull-13 {margin-left:-520px;}
.pull-14 {margin-left:-560px;}
.pull-15 {margin-left:-600px;}
.pull-16 {margin-left:-640px;}
.pull-17 {margin-left:-680px;}
.pull-18 {margin-left:-720px;}
.pull-19 {margin-left:-760px;}
.pull-20 {margin-left:-800px;}
.pull-21 {margin-left:-840px;}
.pull-22 {margin-left:-880px;}
.pull-23 {margin-left:-920px;}
.pull-24 {margin-left:-960px;}
.pull-1, .pull-2, .pull-3, .pull-4, .pull-5, .pull-6, .pull-7, .pull-8, .pull-9, .pull-10, .pull-11, .pull-12, .pull-13, .pull-14, .pull-15, .pull-16, .pull-17, .pull-18, .pull-19, .pull-20, .pull-21, .pull-22, .pull-23, .pull-24 {float:left;position:relative;}
.push-1 {margin:0 -40px 1.5em 40px;}
.push-2 {margin:0 -80px 1.5em 80px;}
.push-3 {margin:0 -120px 1.5em 120px;}
.push-4 {margin:0 -160px 1.5em 160px;}
.push-5 {margin:0 -200px 1.5em 200px;}
.push-6 {margin:0 -240px 1.5em 240px;}
.push-7 {margin:0 -280px 1.5em 280px;}
.push-8 {margin:0 -320px 1.5em 320px;}
.push-9 {margin:0 -360px 1.5em 360px;}
.push-10 {margin:0 -400px 1.5em 400px;}
.push-11 {margin:0 -440px 1.5em 440px;}
.push-12 {margin:0 -480px 1.5em 480px;}
.push-13 {margin:0 -520px 1.5em 520px;}
.push-14 {margin:0 -560px 1.5em 560px;}
.push-15 {margin:0 -600px 1.5em 600px;}
.push-16 {margin:0 -640px 1.5em 640px;}
.push-17 {margin:0 -680px 1.5em 680px;}
.push-18 {margin:0 -720px 1.5em 720px;}
.push-19 {margin:0 -760px 1.5em 760px;}
.push-20 {margin:0 -800px 1.5em 800px;}
.push-21 {margin:0 -840px 1.5em 840px;}
.push-22 {margin:0 -880px 1.5em 880px;}
.push-23 {margin:0 -920px 1.5em 920px;}
.push-24 {margin:0 -960px 1.5em 960px;}
.push-1, .push-2, .push-3, .push-4, .push-5, .push-6, .push-7, .push-8, .push-9, .push-10, .push-11, .push-12, .push-13, .push-14, .push-15, .push-16, .push-17, .push-18, .push-19, .push-20, .push-21, .push-22, .push-23, .push-24 {float:right;position:relative;}
.box {padding:1.5em;margin-bottom:1.5em;background:#E5ECF9;}
hr {background:#ddd;color:#ddd;clear:both;float:none;width:100%;height:.1em;margin:0 0 1.45em;border:none;}
hr.space {background:#fff;color:#fff;}
.clearfix:after, .container:after {content:".";display:block;height:0;clear:both;visibility:hidden;}
.clearfix, .container {display:inline-block;}
* html .clearfix, * html .container {height:1%;}
.clearfix, .container {display:block;}
.clear {clear:both;}
/* forms.css */
label {font-weight:bold;}
fieldset {padding:1.4em;margin:0 0 1.5em 0;border:1px solid #ccc;}
legend {font-weight:bold;font-size:1.2em;}
input.text, input.title, textarea, select {margin:0.5em 0;border:1px solid #bbb;}
input.text:focus, input.title:focus, textarea:focus, select:focus {border:1px solid #666;}
input.text, input.title {width:300px;padding:5px;}
input.title {font-size:1.5em;}
textarea {width:390px;height:250px;padding:5px;}
.error, .notice, .success {padding:.8em;margin-bottom:1em;border:2px solid #ddd;}
.error {background:#FBE3E4;color:#8a1f11;border-color:#FBC2C4;}
.notice {background:#FFF6BF;color:#514721;border-color:#FFD324;}
.success {background:#E6EFC2;color:#264409;border-color:#C6D880;}
.error a {color:#8a1f11;}
.notice a {color:#514721;}
.success a {color:#264409;}

Двоичные данные
build/pgo/blueprint/test-small.jpg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.8 KiB

Двоичные данные
build/pgo/blueprint/test.jpg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 35 KiB

Двоичные данные
build/pgo/blueprint/valid.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.6 KiB

Двоичные данные
build/pgo/favicon.ico Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Просмотреть файл

@ -1,14 +1,208 @@
<html>
<head>
<title>PGO</title>
<script src="quit.js"></script>
</head>
<body>
Just going to quit after a timeout for now...
<script>
setTimeout(goQuitApplication, 10000);
</script>
</body>
</html>
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Automated Testing Code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Bob Clary <bob@bclary.com>
* Jeff Walden <jwalden+code@mit.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function quitHook()
{
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://" + location.host + "/server/shutdown", true);
xhr.onreadystatechange = function (event)
{
if (xhr.readyState == 4)
goQuitApplication();
};
xhr.send(null);
}
function canQuitApplication()
{
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
if (!os)
{
return true;
}
try
{
var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
.createInstance(Components.interfaces.nsISupportsPRBool);
os.notifyObservers(cancelQuit, "quit-application-requested", null);
// Something aborted the quit process.
if (cancelQuit.data)
{
return false;
}
}
catch (ex)
{
}
os.notifyObservers(null, "quit-application-granted", null);
return true;
}
function goQuitApplication()
{
const privs = 'UniversalXPConnect';
try
{
netscape.security.PrivilegeManager.enablePrivilege(privs);
}
catch(ex)
{
throw('goQuitApplication: privilege failure ' + ex);
}
if (!canQuitApplication())
{
return false;
}
const kAppStartup = '@mozilla.org/toolkit/app-startup;1';
const kAppShell = '@mozilla.org/appshell/appShellService;1';
var appService;
var forceQuit;
if (kAppStartup in Components.classes)
{
appService = Components.classes[kAppStartup].
getService(Components.interfaces.nsIAppStartup);
forceQuit = Components.interfaces.nsIAppStartup.eForceQuit;
}
else if (kAppShell in Components.classes)
{
appService = Components.classes[kAppShell].
getService(Components.interfaces.nsIAppShellService);
forceQuit = Components.interfaces.nsIAppShellService.eForceQuit;
}
else
{
throw 'goQuitApplication: no AppStartup/appShell';
}
var windowManager = Components.
classes['@mozilla.org/appshell/window-mediator;1'].getService();
var windowManagerInterface = windowManager.
QueryInterface(Components.interfaces.nsIWindowMediator);
var enumerator = windowManagerInterface.getEnumerator(null);
while (enumerator.hasMoreElements())
{
var domWindow = enumerator.getNext();
if (("tryToClose" in domWindow) && !domWindow.tryToClose())
{
return false;
}
domWindow.close();
}
try
{
appService.quit(forceQuit);
}
catch(ex)
{
throw('goQuitApplication: ' + ex);
}
return true;
}
var list =
[
"blueprint/sample.html",
"blueprint/forms.html",
"blueprint/grid.html",
"blueprint/elements.html",
"js-input/3d-cube.html",
"js-input/3d-morph.html",
"js-input/3d-raytrace.html",
"js-input/3d-thingy.html",
"js-input/access-binary-trees.html",
"js-input/access-fannkuch.html",
"js-input/access-nbody.html",
"js-input/access-nsieve.html",
"js-input/bitops-3bit-bits-in-byte.html",
"js-input/bitops-bits-in-byte.html",
"js-input/bitops-bitwise-and.html",
"js-input/bitops-nsieve-bits.html",
"js-input/controlflow-recursive.html",
"js-input/crypto-aes.html",
"js-input/crypto-md5.html",
"js-input/crypto-sha1.html",
"js-input/crypto-otp.html",
"js-input/date-format-tofte.html",
"js-input/date-format-xparb.html",
"js-input/math-cordic.html",
"js-input/math-partial-sums.html",
"js-input/math-spectral-norm.html",
"js-input/regexp-dna.html",
"js-input/string-base64.html",
"js-input/string-fasta.html",
"js-input/string-tagcloud.html",
"js-input/string-unpack-code.html",
"js-input/string-validate-input.html"
];
var interval = 3000; // 15000
var idx = 0;
var w;
window.onload = function () {
w = window.open("about:blank");
window.setTimeout(loadURL, interval);
};
function loadURL () {
w.location.href = list[idx++];
if (idx < list.length) {
window.setTimeout(loadURL, interval);
} else {
window.setTimeout(goQuitApplication, interval);
}
}
var i;
for(i=0; i < list.length;i++) {
document.write(list[i]);
document.write("<br>");
}
</script>

Просмотреть файл

@ -0,0 +1,387 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider 3d-cube</title>
</head>
<body>
<h3>3d-cube</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
// 3D Cube Rotation
// http://www.speich.net/computer/moztesting/3d.htm
// Created by Simon Speich
var Q = new Array();
var MTrans = new Array(); // transformation matrix
var MQube = new Array(); // position information of qube
var I = new Array(); // entity matrix
var Origin = new Object();
var Testing = new Object();
var LoopTimer;
var DisplArea = new Object();
DisplArea.Width = 300;
DisplArea.Height = 300;
function DrawLine(From, To) {
var x1 = From.V[0];
var x2 = To.V[0];
var y1 = From.V[1];
var y2 = To.V[1];
var dx = Math.abs(x2 - x1);
var dy = Math.abs(y2 - y1);
var x = x1;
var y = y1;
var IncX1, IncY1;
var IncX2, IncY2;
var Den;
var Num;
var NumAdd;
var NumPix;
if (x2 >= x1) { IncX1 = 1; IncX2 = 1; }
else { IncX1 = -1; IncX2 = -1; }
if (y2 >= y1) { IncY1 = 1; IncY2 = 1; }
else { IncY1 = -1; IncY2 = -1; }
if (dx >= dy) {
IncX1 = 0;
IncY2 = 0;
Den = dx;
Num = dx / 2;
NumAdd = dy;
NumPix = dx;
}
else {
IncX2 = 0;
IncY1 = 0;
Den = dy;
Num = dy / 2;
NumAdd = dx;
NumPix = dy;
}
NumPix = Math.round(Q.LastPx + NumPix);
var i = Q.LastPx;
for (; i < NumPix; i++) {
Num += NumAdd;
if (Num >= Den) {
Num -= Den;
x += IncX1;
y += IncY1;
}
x += IncX2;
y += IncY2;
}
Q.LastPx = NumPix;
}
function CalcCross(V0, V1) {
var Cross = new Array();
Cross[0] = V0[1]*V1[2] - V0[2]*V1[1];
Cross[1] = V0[2]*V1[0] - V0[0]*V1[2];
Cross[2] = V0[0]*V1[1] - V0[1]*V1[0];
return Cross;
}
function CalcNormal(V0, V1, V2) {
var A = new Array(); var B = new Array();
for (var i = 0; i < 3; i++) {
A[i] = V0[i] - V1[i];
B[i] = V2[i] - V1[i];
}
A = CalcCross(A, B);
var Length = Math.sqrt(A[0]*A[0] + A[1]*A[1] + A[2]*A[2]);
for (var i = 0; i < 3; i++) A[i] = A[i] / Length;
A[3] = 1;
return A;
}
function CreateP(X,Y,Z) {
this.V = [X,Y,Z,1];
}
// multiplies two matrices
function MMulti(M1, M2) {
var M = [[],[],[],[]];
var i = 0;
var j = 0;
for (; i < 4; i++) {
j = 0;
for (; j < 4; j++) M[i][j] = M1[i][0] * M2[0][j] + M1[i][1] * M2[1][j] + M1[i][2] * M2[2][j] + M1[i][3] * M2[3][j];
}
return M;
}
//multiplies matrix with vector
function VMulti(M, V) {
var Vect = new Array();
var i = 0;
for (;i < 4; i++) Vect[i] = M[i][0] * V[0] + M[i][1] * V[1] + M[i][2] * V[2] + M[i][3] * V[3];
return Vect;
}
function VMulti2(M, V) {
var Vect = new Array();
var i = 0;
for (;i < 3; i++) Vect[i] = M[i][0] * V[0] + M[i][1] * V[1] + M[i][2] * V[2];
return Vect;
}
// add to matrices
function MAdd(M1, M2) {
var M = [[],[],[],[]];
var i = 0;
var j = 0;
for (; i < 4; i++) {
j = 0;
for (; j < 4; j++) M[i][j] = M1[i][j] + M2[i][j];
}
return M;
}
function Translate(M, Dx, Dy, Dz) {
var T = [
[1,0,0,Dx],
[0,1,0,Dy],
[0,0,1,Dz],
[0,0,0,1]
];
return MMulti(T, M);
}
function RotateX(M, Phi) {
var a = Phi;
a *= Math.PI / 180;
var Cos = Math.cos(a);
var Sin = Math.sin(a);
var R = [
[1,0,0,0],
[0,Cos,-Sin,0],
[0,Sin,Cos,0],
[0,0,0,1]
];
return MMulti(R, M);
}
function RotateY(M, Phi) {
var a = Phi;
a *= Math.PI / 180;
var Cos = Math.cos(a);
var Sin = Math.sin(a);
var R = [
[Cos,0,Sin,0],
[0,1,0,0],
[-Sin,0,Cos,0],
[0,0,0,1]
];
return MMulti(R, M);
}
function RotateZ(M, Phi) {
var a = Phi;
a *= Math.PI / 180;
var Cos = Math.cos(a);
var Sin = Math.sin(a);
var R = [
[Cos,-Sin,0,0],
[Sin,Cos,0,0],
[0,0,1,0],
[0,0,0,1]
];
return MMulti(R, M);
}
function DrawQube() {
// calc current normals
var CurN = new Array();
var i = 5;
Q.LastPx = 0;
for (; i > -1; i--) CurN[i] = VMulti2(MQube, Q.Normal[i]);
if (CurN[0][2] < 0) {
if (!Q.Line[0]) { DrawLine(Q[0], Q[1]); Q.Line[0] = true; };
if (!Q.Line[1]) { DrawLine(Q[1], Q[2]); Q.Line[1] = true; };
if (!Q.Line[2]) { DrawLine(Q[2], Q[3]); Q.Line[2] = true; };
if (!Q.Line[3]) { DrawLine(Q[3], Q[0]); Q.Line[3] = true; };
}
if (CurN[1][2] < 0) {
if (!Q.Line[2]) { DrawLine(Q[3], Q[2]); Q.Line[2] = true; };
if (!Q.Line[9]) { DrawLine(Q[2], Q[6]); Q.Line[9] = true; };
if (!Q.Line[6]) { DrawLine(Q[6], Q[7]); Q.Line[6] = true; };
if (!Q.Line[10]) { DrawLine(Q[7], Q[3]); Q.Line[10] = true; };
}
if (CurN[2][2] < 0) {
if (!Q.Line[4]) { DrawLine(Q[4], Q[5]); Q.Line[4] = true; };
if (!Q.Line[5]) { DrawLine(Q[5], Q[6]); Q.Line[5] = true; };
if (!Q.Line[6]) { DrawLine(Q[6], Q[7]); Q.Line[6] = true; };
if (!Q.Line[7]) { DrawLine(Q[7], Q[4]); Q.Line[7] = true; };
}
if (CurN[3][2] < 0) {
if (!Q.Line[4]) { DrawLine(Q[4], Q[5]); Q.Line[4] = true; };
if (!Q.Line[8]) { DrawLine(Q[5], Q[1]); Q.Line[8] = true; };
if (!Q.Line[0]) { DrawLine(Q[1], Q[0]); Q.Line[0] = true; };
if (!Q.Line[11]) { DrawLine(Q[0], Q[4]); Q.Line[11] = true; };
}
if (CurN[4][2] < 0) {
if (!Q.Line[11]) { DrawLine(Q[4], Q[0]); Q.Line[11] = true; };
if (!Q.Line[3]) { DrawLine(Q[0], Q[3]); Q.Line[3] = true; };
if (!Q.Line[10]) { DrawLine(Q[3], Q[7]); Q.Line[10] = true; };
if (!Q.Line[7]) { DrawLine(Q[7], Q[4]); Q.Line[7] = true; };
}
if (CurN[5][2] < 0) {
if (!Q.Line[8]) { DrawLine(Q[1], Q[5]); Q.Line[8] = true; };
if (!Q.Line[5]) { DrawLine(Q[5], Q[6]); Q.Line[5] = true; };
if (!Q.Line[9]) { DrawLine(Q[6], Q[2]); Q.Line[9] = true; };
if (!Q.Line[1]) { DrawLine(Q[2], Q[1]); Q.Line[1] = true; };
}
Q.Line = [false,false,false,false,false,false,false,false,false,false,false,false];
Q.LastPx = 0;
}
function Loop() {
if (Testing.LoopCount > Testing.LoopMax) return;
var TestingStr = String(Testing.LoopCount);
while (TestingStr.length < 3) TestingStr = "0" + TestingStr;
MTrans = Translate(I, -Q[8].V[0], -Q[8].V[1], -Q[8].V[2]);
MTrans = RotateX(MTrans, 1);
MTrans = RotateY(MTrans, 3);
MTrans = RotateZ(MTrans, 5);
MTrans = Translate(MTrans, Q[8].V[0], Q[8].V[1], Q[8].V[2]);
MQube = MMulti(MTrans, MQube);
var i = 8;
for (; i > -1; i--) {
Q[i].V = VMulti(MTrans, Q[i].V);
}
DrawQube();
Testing.LoopCount++;
Loop();
}
function Init(CubeSize) {
// init/reset vars
Origin.V = [150,150,20,1];
Testing.LoopCount = 0;
Testing.LoopMax = 50;
Testing.TimeMax = 0;
Testing.TimeAvg = 0;
Testing.TimeMin = 0;
Testing.TimeTemp = 0;
Testing.TimeTotal = 0;
Testing.Init = false;
// transformation matrix
MTrans = [
[1,0,0,0],
[0,1,0,0],
[0,0,1,0],
[0,0,0,1]
];
// position information of qube
MQube = [
[1,0,0,0],
[0,1,0,0],
[0,0,1,0],
[0,0,0,1]
];
// entity matrix
I = [
[1,0,0,0],
[0,1,0,0],
[0,0,1,0],
[0,0,0,1]
];
// create qube
Q[0] = new CreateP(-CubeSize,-CubeSize, CubeSize);
Q[1] = new CreateP(-CubeSize, CubeSize, CubeSize);
Q[2] = new CreateP( CubeSize, CubeSize, CubeSize);
Q[3] = new CreateP( CubeSize,-CubeSize, CubeSize);
Q[4] = new CreateP(-CubeSize,-CubeSize,-CubeSize);
Q[5] = new CreateP(-CubeSize, CubeSize,-CubeSize);
Q[6] = new CreateP( CubeSize, CubeSize,-CubeSize);
Q[7] = new CreateP( CubeSize,-CubeSize,-CubeSize);
// center of gravity
Q[8] = new CreateP(0, 0, 0);
// anti-clockwise edge check
Q.Edge = [[0,1,2],[3,2,6],[7,6,5],[4,5,1],[4,0,3],[1,5,6]];
// calculate squad normals
Q.Normal = new Array();
for (var i = 0; i < Q.Edge.length; i++) Q.Normal[i] = CalcNormal(Q[Q.Edge[i][0]].V, Q[Q.Edge[i][1]].V, Q[Q.Edge[i][2]].V);
// line drawn ?
Q.Line = [false,false,false,false,false,false,false,false,false,false,false,false];
// create line pixels
Q.NumPx = 9 * 2 * CubeSize;
for (var i = 0; i < Q.NumPx; i++) CreateP(0,0,0);
MTrans = Translate(MTrans, Origin.V[0], Origin.V[1], Origin.V[2]);
MQube = MMulti(MTrans, MQube);
var i = 0;
for (; i < 9; i++) {
Q[i].V = VMulti(MTrans, Q[i].V);
}
DrawQube();
Testing.Init = true;
Loop();
}
for ( var i = 20; i <= 160; i *= 2 ) {
Init(i);
}
Q = null;
MTrans = null;
MQube = null;
I = null;
Origin = null;
Testing = null;
LoopTime = null;
DisplArea = null;
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,104 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider 3d-morph</title>
</head>
<body>
<h3>3d-morph</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
var loops = 15
var nx = 120
var nz = 120
function morph(a, f) {
var PI2nx = Math.PI * 8/nx
var sin = Math.sin
var f30 = -(50 * sin(f*Math.PI*2))
for (var i = 0; i < nz; ++i) {
for (var j = 0; j < nx; ++j) {
a[3*(i*nx+j)+1] = sin((j-1) * PI2nx ) * -f30
}
}
}
var a = Array()
for (var i=0; i < nx*nz*3; ++i)
a[i] = 0
for (var i = 0; i < loops; ++i) {
morph(a, i/loops)
}
testOutput = 0;
for (var i = 0; i < nx; i++)
testOutput += a[3*(i*nx+i)+1];
a = null;
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,490 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider 3d-raytrace</title>
</head>
<body>
<h3>3d-raytrace</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
function createVector(x,y,z) {
return new Array(x,y,z);
}
function sqrLengthVector(self) {
return self[0] * self[0] + self[1] * self[1] + self[2] * self[2];
}
function lengthVector(self) {
return Math.sqrt(self[0] * self[0] + self[1] * self[1] + self[2] * self[2]);
}
function addVector(self, v) {
self[0] += v[0];
self[1] += v[1];
self[2] += v[2];
return self;
}
function subVector(self, v) {
self[0] -= v[0];
self[1] -= v[1];
self[2] -= v[2];
return self;
}
function scaleVector(self, scale) {
self[0] *= scale;
self[1] *= scale;
self[2] *= scale;
return self;
}
function normaliseVector(self) {
var len = Math.sqrt(self[0] * self[0] + self[1] * self[1] + self[2] * self[2]);
self[0] /= len;
self[1] /= len;
self[2] /= len;
return self;
}
function add(v1, v2) {
return new Array(v1[0] + v2[0], v1[1] + v2[1], v1[2] + v2[2]);
}
function sub(v1, v2) {
return new Array(v1[0] - v2[0], v1[1] - v2[1], v1[2] - v2[2]);
}
function scalev(v1, v2) {
return new Array(v1[0] * v2[0], v1[1] * v2[1], v1[2] * v2[2]);
}
function dot(v1, v2) {
return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
}
function scale(v, scale) {
return [v[0] * scale, v[1] * scale, v[2] * scale];
}
function cross(v1, v2) {
return [v1[1] * v2[2] - v1[2] * v2[1],
v1[2] * v2[0] - v1[0] * v2[2],
v1[0] * v2[1] - v1[1] * v2[0]];
}
function normalise(v) {
var len = lengthVector(v);
return [v[0] / len, v[1] / len, v[2] / len];
}
function transformMatrix(self, v) {
var vals = self;
var x = vals[0] * v[0] + vals[1] * v[1] + vals[2] * v[2] + vals[3];
var y = vals[4] * v[0] + vals[5] * v[1] + vals[6] * v[2] + vals[7];
var z = vals[8] * v[0] + vals[9] * v[1] + vals[10] * v[2] + vals[11];
return [x, y, z];
}
function invertMatrix(self) {
var temp = new Array(16);
var tx = -self[3];
var ty = -self[7];
var tz = -self[11];
for (h = 0; h < 3; h++)
for (v = 0; v < 3; v++)
temp[h + v * 4] = self[v + h * 4];
for (i = 0; i < 11; i++)
self[i] = temp[i];
self[3] = tx * self[0] + ty * self[1] + tz * self[2];
self[7] = tx * self[4] + ty * self[5] + tz * self[6];
self[11] = tx * self[8] + ty * self[9] + tz * self[10];
return self;
}
// Triangle intersection using barycentric coord method
function Triangle(p1, p2, p3) {
var edge1 = sub(p3, p1);
var edge2 = sub(p2, p1);
var normal = cross(edge1, edge2);
if (Math.abs(normal[0]) > Math.abs(normal[1]))
if (Math.abs(normal[0]) > Math.abs(normal[2]))
this.axis = 0;
else
this.axis = 2;
else
if (Math.abs(normal[1]) > Math.abs(normal[2]))
this.axis = 1;
else
this.axis = 2;
var u = (this.axis + 1) % 3;
var v = (this.axis + 2) % 3;
var u1 = edge1[u];
var v1 = edge1[v];
var u2 = edge2[u];
var v2 = edge2[v];
this.normal = normalise(normal);
this.nu = normal[u] / normal[this.axis];
this.nv = normal[v] / normal[this.axis];
this.nd = dot(normal, p1) / normal[this.axis];
var det = u1 * v2 - v1 * u2;
this.eu = p1[u];
this.ev = p1[v];
this.nu1 = u1 / det;
this.nv1 = -v1 / det;
this.nu2 = v2 / det;
this.nv2 = -u2 / det;
this.material = [0.7, 0.7, 0.7];
}
Triangle.prototype.intersect = function(orig, dir, near, far) {
var u = (this.axis + 1) % 3;
var v = (this.axis + 2) % 3;
var d = dir[this.axis] + this.nu * dir[u] + this.nv * dir[v];
var t = (this.nd - orig[this.axis] - this.nu * orig[u] - this.nv * orig[v]) / d;
if (t < near || t > far)
return null;
var Pu = orig[u] + t * dir[u] - this.eu;
var Pv = orig[v] + t * dir[v] - this.ev;
var a2 = Pv * this.nu1 + Pu * this.nv1;
if (a2 < 0)
return null;
var a3 = Pu * this.nu2 + Pv * this.nv2;
if (a3 < 0)
return null;
if ((a2 + a3) > 1)
return null;
return t;
}
function Scene(a_triangles) {
this.triangles = a_triangles;
this.lights = [];
this.ambient = [0,0,0];
this.background = [0.8,0.8,1];
}
var zero = new Array(0,0,0);
Scene.prototype.intersect = function(origin, dir, near, far) {
var closest = null;
for (i = 0; i < this.triangles.length; i++) {
var triangle = this.triangles[i];
var d = triangle.intersect(origin, dir, near, far);
if (d == null || d > far || d < near)
continue;
far = d;
closest = triangle;
}
if (!closest)
return [this.background[0],this.background[1],this.background[2]];
var normal = closest.normal;
var hit = add(origin, scale(dir, far));
if (dot(dir, normal) > 0)
normal = [-normal[0], -normal[1], -normal[2]];
var colour = null;
if (closest.shader) {
colour = closest.shader(closest, hit, dir);
} else {
colour = closest.material;
}
// do reflection
var reflected = null;
if (colour.reflection > 0.001) {
var reflection = addVector(scale(normal, -2*dot(dir, normal)), dir);
reflected = this.intersect(hit, reflection, 0.0001, 1000000);
if (colour.reflection >= 0.999999)
return reflected;
}
var l = [this.ambient[0], this.ambient[1], this.ambient[2]];
for (var i = 0; i < this.lights.length; i++) {
var light = this.lights[i];
var toLight = sub(light, hit);
var distance = lengthVector(toLight);
scaleVector(toLight, 1.0/distance);
distance -= 0.0001;
if (this.blocked(hit, toLight, distance))
continue;
var nl = dot(normal, toLight);
if (nl > 0)
addVector(l, scale(light.colour, nl));
}
l = scalev(l, colour);
if (reflected) {
l = addVector(scaleVector(l, 1 - colour.reflection), scaleVector(reflected, colour.reflection));
}
return l;
}
Scene.prototype.blocked = function(O, D, far) {
var near = 0.0001;
var closest = null;
for (i = 0; i < this.triangles.length; i++) {
var triangle = this.triangles[i];
var d = triangle.intersect(O, D, near, far);
if (d == null || d > far || d < near)
continue;
return true;
}
return false;
}
// this camera code is from notes i made ages ago, it is from *somewhere* -- i cannot remember where
// that somewhere is
function Camera(origin, lookat, up) {
var zaxis = normaliseVector(subVector(lookat, origin));
var xaxis = normaliseVector(cross(up, zaxis));
var yaxis = normaliseVector(cross(xaxis, subVector([0,0,0], zaxis)));
var m = new Array(16);
m[0] = xaxis[0]; m[1] = xaxis[1]; m[2] = xaxis[2];
m[4] = yaxis[0]; m[5] = yaxis[1]; m[6] = yaxis[2];
m[8] = zaxis[0]; m[9] = zaxis[1]; m[10] = zaxis[2];
invertMatrix(m);
m[3] = 0; m[7] = 0; m[11] = 0;
this.origin = origin;
this.directions = new Array(4);
this.directions[0] = normalise([-0.7, 0.7, 1]);
this.directions[1] = normalise([ 0.7, 0.7, 1]);
this.directions[2] = normalise([ 0.7, -0.7, 1]);
this.directions[3] = normalise([-0.7, -0.7, 1]);
this.directions[0] = transformMatrix(m, this.directions[0]);
this.directions[1] = transformMatrix(m, this.directions[1]);
this.directions[2] = transformMatrix(m, this.directions[2]);
this.directions[3] = transformMatrix(m, this.directions[3]);
}
Camera.prototype.generateRayPair = function(y) {
rays = new Array(new Object(), new Object());
rays[0].origin = this.origin;
rays[1].origin = this.origin;
rays[0].dir = addVector(scale(this.directions[0], y), scale(this.directions[3], 1 - y));
rays[1].dir = addVector(scale(this.directions[1], y), scale(this.directions[2], 1 - y));
return rays;
}
function renderRows(camera, scene, pixels, width, height, starty, stopy) {
for (var y = starty; y < stopy; y++) {
var rays = camera.generateRayPair(y / height);
for (var x = 0; x < width; x++) {
var xp = x / width;
var origin = addVector(scale(rays[0].origin, xp), scale(rays[1].origin, 1 - xp));
var dir = normaliseVector(addVector(scale(rays[0].dir, xp), scale(rays[1].dir, 1 - xp)));
var l = scene.intersect(origin, dir);
pixels[y][x] = l;
}
}
}
Camera.prototype.render = function(scene, pixels, width, height) {
var cam = this;
var row = 0;
renderRows(cam, scene, pixels, width, height, 0, height);
}
function raytraceScene()
{
var startDate = new Date().getTime();
var numTriangles = 2 * 6;
var triangles = new Array();//numTriangles);
var tfl = createVector(-10, 10, -10);
var tfr = createVector( 10, 10, -10);
var tbl = createVector(-10, 10, 10);
var tbr = createVector( 10, 10, 10);
var bfl = createVector(-10, -10, -10);
var bfr = createVector( 10, -10, -10);
var bbl = createVector(-10, -10, 10);
var bbr = createVector( 10, -10, 10);
// cube!!!
// front
var i = 0;
triangles[i++] = new Triangle(tfl, tfr, bfr);
triangles[i++] = new Triangle(tfl, bfr, bfl);
// back
triangles[i++] = new Triangle(tbl, tbr, bbr);
triangles[i++] = new Triangle(tbl, bbr, bbl);
// triangles[i-1].material = [0.7,0.2,0.2];
// triangles[i-1].material.reflection = 0.8;
// left
triangles[i++] = new Triangle(tbl, tfl, bbl);
// triangles[i-1].reflection = 0.6;
triangles[i++] = new Triangle(tfl, bfl, bbl);
// triangles[i-1].reflection = 0.6;
// right
triangles[i++] = new Triangle(tbr, tfr, bbr);
triangles[i++] = new Triangle(tfr, bfr, bbr);
// top
triangles[i++] = new Triangle(tbl, tbr, tfr);
triangles[i++] = new Triangle(tbl, tfr, tfl);
// bottom
triangles[i++] = new Triangle(bbl, bbr, bfr);
triangles[i++] = new Triangle(bbl, bfr, bfl);
//Floor!!!!
var green = createVector(0.0, 0.4, 0.0);
var grey = createVector(0.4, 0.4, 0.4);
grey.reflection = 1.0;
var floorShader = function(tri, pos, view) {
var x = ((pos[0]/32) % 2 + 2) % 2;
var z = ((pos[2]/32 + 0.3) % 2 + 2) % 2;
if (x < 1 != z < 1) {
//in the real world we use the fresnel term...
// var angle = 1-dot(view, tri.normal);
// angle *= angle;
// angle *= angle;
// angle *= angle;
//grey.reflection = angle;
return grey;
} else
return green;
}
var ffl = createVector(-1000, -30, -1000);
var ffr = createVector( 1000, -30, -1000);
var fbl = createVector(-1000, -30, 1000);
var fbr = createVector( 1000, -30, 1000);
triangles[i++] = new Triangle(fbl, fbr, ffr);
triangles[i-1].shader = floorShader;
triangles[i++] = new Triangle(fbl, ffr, ffl);
triangles[i-1].shader = floorShader;
var _scene = new Scene(triangles);
_scene.lights[0] = createVector(20, 38, -22);
_scene.lights[0].colour = createVector(0.7, 0.3, 0.3);
_scene.lights[1] = createVector(-23, 40, 17);
_scene.lights[1].colour = createVector(0.7, 0.3, 0.3);
_scene.lights[2] = createVector(23, 20, 17);
_scene.lights[2].colour = createVector(0.7, 0.7, 0.7);
_scene.ambient = createVector(0.1, 0.1, 0.1);
// _scene.background = createVector(0.7, 0.7, 1.0);
var size = 30;
var pixels = new Array();
for (var y = 0; y < size; y++) {
pixels[y] = new Array();
for (var x = 0; x < size; x++) {
pixels[y][x] = 0;
}
}
var _camera = new Camera(createVector(-40, 40, 40), createVector(0, 0, 0), createVector(0, 1, 0));
_camera.render(_scene, pixels, size, size);
return pixels;
}
function arrayToCanvasCommands(pixels)
{
var s = '<canvas id="renderCanvas" width="30px" height="30px"></canvas><scr' + 'ipt>\nvar pixels = [';
var size = 30;
for (var y = 0; y < size; y++) {
s += "[";
for (var x = 0; x < size; x++) {
s += "[" + pixels[y][x] + "],";
}
s+= "],";
}
s += '];\n var canvas = document.getElementById("renderCanvas").getContext("2d");\n\
\n\
\n\
var size = 30;\n\
canvas.fillStyle = "red";\n\
canvas.fillRect(0, 0, size, size);\n\
canvas.scale(1, -1);\n\
canvas.translate(0, -size);\n\
\n\
if (!canvas.setFillColor)\n\
canvas.setFillColor = function(r, g, b, a) {\n\
this.fillStyle = "rgb("+[Math.floor(r * 255), Math.floor(g * 255), Math.floor(b * 255)]+")";\n\
}\n\
\n\
for (var y = 0; y < size; y++) {\n\
for (var x = 0; x < size; x++) {\n\
var l = pixels[y][x];\n\
canvas.setFillColor(l[0], l[1], l[2], 1);\n\
canvas.fillRect(x, y, 1, 1);\n\
}\n\
}</scr' + 'ipt>';
return s;
}
testOutput = arrayToCanvasCommands(raytraceScene());
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,390 @@
<html>
<head>
<title>3d thingy</title>
<style type="text/css">
div.z2 { position:absolute; z-index:2; }
div.z1 { position:absolute; z-index:1; }
</style>
<script type="text/javascript">
/**************************************************************************
JavaScript Graphics Library 0.0.1, Updated Source Code at Scriptersoft.com
Copyright (C) 2005 Kurt L. Whicher
November,13,2005
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
**************************************************************************/
//________________________________________ global variables
var S_piDoubled=Math.PI*2;
var S_deg2Rad=Math.PI/180;
//_______________________________________________ functions
function S_matrix() {
return [1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1];
}
function S_vec2D(x,y) { this.x=x; this.y=y; }
function S_vec3D(x,y,z) { this.x=x; this.y=y; this.z=z; }
function S_subVec2D(a,b) {
return new S_vec2D(a.x-b.x, a.y-b.y);
}
function S_subVec3D(a,b) {
return new S_vec3D(a.x-b.x, a.y-b.y, a.z-b.z);
}
function S_dotVec3D(a, b) { return a.x*b.x+a.y*b.y+a.z*b.z; }
function S_cross(a,b) {
return new S_vec3D( a.y*b.z-a.z*b.y, a.z*b.x-a.x*b.z, a.x*b.y-a.y*b.x);
}
function S_lengthSquaredVec3D(v) { return S_dotVec3D(v,v); }
function S_lengthVec3D(v) { return Math.sqrt(S_lengthSquaredVec3D(v)); }
function S_normalizeVec3D(v) {
var l=S_lengthVec3D(v), nv=new S_vec3D(0,0,0);
if(l!=0) { nv.x=v.x/l; nv.y=v.y/l; nv.z=v.z/l; }
return nv;
}
function S_rotate(m,ax,a) { // transformation matrix, axis, angle
var i,j,ij=new Array(),v=new Array(),c=Math.cos(a),s=Math.sin(a);
if (ax=="x") ij=[1,2,5,6,9,10,13,14];
else if (ax=="y") ij=[2,0,6,4,10,8,14,12];
else if (ax=="z") ij=[0,1,4,5,8,9,12,13];
for (i=0;i<8;i++) v[i]=m[ij[i]];
for (i=0,j=1;i<8;i+=2,j+=2) {
m[ij[i]]=v[i]*c-v[j]*s;
m[ij[j]]=v[i]*s+v[j]*c
}
}
function S_checkBrowser() {
if (document.getElementById) return true; else return false;
}
function S_zIndex(e,z) { document.getElementById(e).style.zIndex=z; }
function S_rgbColor(r,g,b) {
var i, c=[r,g,b];
for(i=0; i<3; i++) {
c[i]=Math.floor(c[i]);
if(c[i]<0) c[i]=0; else if(c[i]>255) c[i]=255;
}
return c;
}
function S_rgbColorString(c) {
return "rgb("+c[0]+","+c[1]+","+c[2]+")";
}
function S_vertice(x,y,z) {
this.x=x; this.y=y; this.z=z; this.w=1;
this.t=new S_vec3D(x,y,z); // transformed 3d
this.p=new S_vec2D(0,0); // projected 2d
}
function S_face(v0,v1,v2,c) { // 3 vertice faces
this.v=[v0,v1,v2]; this.c=c; this.b=0; // b:brightness
this.d=true; // display: true or false
}
// x coordinate, number of vertices, distance
function S_verticeRing(x,nv,d) {
var i,a,v=new Array();
for(i=0;i<nv;i++) {
a=S_piDoubled*i/nv;
v[i]=new S_vertice(x,d*Math.sin(a),d*Math.cos(a));
}
return v;
}
function S_triangleRing(r1,r2,c,clr) { // rows 1 & 2, cols, color
var i,j,tr=new Array();
for(i=0,j=1;i<c;i++,j=++j%c) {
tr.push(new S_face(r1+i,r2+i,r2+j,clr));
tr.push(new S_face(r1+i,r2+j,r1+j,clr));
}
return tr;
}
function S_model(v,f) {
// vertice & face arrays, transformation matrix, display boolean
this.v=v; this.f=f, this.tm=S_matrix(), this.d=true;
}
S_model.prototype.S_rotateX=function(a) {
S_rotate(this.tm,"x",a*=S_deg2Rad);
}
S_model.prototype.S_rotateY=function(a) {
S_rotate(this.tm,"y",a*=S_deg2Rad);
}
S_model.prototype.S_rotateZ=function(a) {
S_rotate(this.tm,"z",a*=S_deg2Rad);
}
S_model.prototype.S_show=function() { this.d=true; }
S_model.prototype.S_hide=function() { this.d=false; }
function S_cube(d,c) { //distance & color
return new S_cone(d,d,Math.cos(Math.PI/4)*d*2,1,4,c);
}
function S_cylinder(w,h,r,c,clr,e) {
return new S_cone(w,w,h,r,c,clr,e);
}
// width, height, "rows", "columns", color, ends
function S_cone(w1,w2,h,r,c,clr,e) {
var i,r1=0,r2=c,v=new Array(),t=new Array(),rxc=r*c;
for(i=0;i<=r;i++)
v=v.concat(S_verticeRing(h*(0.5-i/r),c,w1*i/r+w2*(r-i)/r));
for(i=0;i<r;i++,r1+=c,r2+=c)
t=t.concat(S_triangleRing(r1,r2,c,clr));
if (e!="hideEnds")
for(i=1;i<(c-1);i++) {
t.push(new S_face(0,i,i+1,clr));
t.push(new S_face(rxc,rxc+i+1,rxc+i,clr));
}
return new S_model(v,t);
}
function S_sphere(d,r,c,clr) {
// distance, "rows">=2, "columns">=3, color paramaters
var v=new Array(),t=new Array(),r_1xc=(r-1)*c,r_2xc=(r-2)*c;
var i,j,tmp,r1=0,r2=c;
for(i=1;i<r;i++) {
tmp=Math.PI*i/r;
v=v.concat(S_verticeRing(d*Math.cos(tmp),c,Math.sin(tmp)*d));
}
v.push(new S_vertice( d,0,0));
v.push(new S_vertice(-d,0,0));
for(i=0;i<(r-2);i++,r1+=c,r2+=c)
t=t.concat(S_triangleRing(r1,r2,c,clr));
for(i=0,j=1;i<c;i++,j=++j%c) {
t.push(new S_face(r_1xc,i,j,clr));
t.push(new S_face(r_1xc+1,r_2xc+j,r_2xc+i,clr));
}
return new S_model(v,t);
}
S_model.prototype.S_scale=function(x) {
this.tm[0]*=x; this.tm[5]*=x; this.tm[10]*=x;
}
S_model.prototype.S_faceColor=function(i,c) { this.f[i].c=c; }
S_model.prototype.S_scaleX=function(s) { this.tm[0]*=s; }
S_model.prototype.S_scaleY=function(s) { this.tm[5]*=s; }
S_model.prototype.S_scaleZ=function(s) { this.tm[10]*=s; }
function S_scene(dv,l,t,w,h,cmra) { // left, top, width, height
this.dv=dv;
this.ps=1; // pixel size
this.l=l; this.t=t; this.w=w; this.h=h;
this.cx=l+w/2; this.cy=t+h/2; // center x, center y
this.dt="paint"; // output type
this.m=new Array(); // model array
this.lght=new S_light();
this.lc=S_rgbColor(255,255,255); // light color
this.cmra=-cmra; // camera on z axis
this.bfr=S_buffer(h,w);
}
function S_buffer(h,w) {
var i, j, b=new Array();
for(i=0;i<h;i++) {
b[i]=new Array();
for(j=0;j<w;j++) b[i][j]=new S_pixel();
}
return b;
}
function S_pixel() { // display boolean, color
this.d=true; this.c=0;
}
S_pixel.prototype.S_setColor=function(c) {
this.d=true; this.c=c;
}
S_pixel.prototype.S_hide=function() { this.d=false; }
S_scene.prototype.S_pixelSize=function(ps){ this.ps=ps; }
S_scene.prototype.S_widthAndHeight=function(w,h){ this.w=w; this.h=h; }
S_scene.prototype.S_center=function(cx,cy){ this.cx=cx; this.cy=cy; }
S_scene.prototype.S_paint=function(){ this.dt="paint"; }
S_scene.prototype.S_models=function() {
var i; this.m=new Array();
for(i=0;i<arguments.length;i++) this.m.push(arguments[i]);
}
S_scene.prototype.S_lightColor=function(c){ this.lc=c; }
S_scene.prototype.S_project=function() {
var i, j, v, tm, d, m;
for(i=0;i<this.m.length;i++) {
m=this.m[i]; tm=this.m[i].tm;
for(j=0;j<m.v.length;j++) {
v=m.v[j];
v.t.x=v.x*tm[0]+v.y*tm[4]+v.z*tm[8]+v.w*tm[12];
v.t.y=v.x*tm[1]+v.y*tm[5]+v.z*tm[9]+v.w*tm[13];
v.t.z=v.x*tm[2]+v.y*tm[6]+v.z*tm[10]+v.w*tm[14];
d=(this.cmra-v.t.z/2);
if (d<0) {
v.p.x=(this.cmra*v.t.x/d)+this.cx;
v.p.y=-(this.cmra*v.t.y/d)+this.cy;
}
}
}
}
S_scene.prototype.S_display=function(disp){
var i, j, k, s="", ds, c, cnt=0; // ds:div start
this.tr=new Array(); // triangles ready to draw
this.S_project();
this.S_adjustLight();
this.S_clearBuffer();
for(i=0;i<this.m.length;i++) {
this.m[i].S_setupFaces(this.tr,this.lght.t);
for(j=0;j<this.tr.length;j++) { // loop through triangles
c=S_divColor(this.tr[j].c,this.lc,this.tr[j].b);
S_setupBuffer(this,this.tr[j].p,c);
}
}
for(i=0;i<this.h;i++) {
ds=-1;
for(j=0,k=1;j<this.w;j++,k++) {
if((this.bfr[i][j].d==true)&&(ds==-1)) ds=j;
if( (this.bfr[i][j].d==true)&&
( (k==this.w)||
(this.bfr[i][k].d==false)||
(!S_sameColor(this.bfr[i][j].c, this.bfr[i][k].c)) ) ) {
s+=S_divString(S_rgbColorString(this.bfr[i][j].c),this.t+i*this.ps,this.l+ds*this.ps,this.ps,(k-ds)*this.ps);
ds=-1;
cnt++;
}
}
}
S_writeInnerHTML(this.dv,s);
if(disp=="ShowCount") alert(cnt);
}
S_scene.prototype.S_displayAndShowCount=function(){
this.S_display("ShowCount");
}
S_model.prototype.S_setupFaces=function(tr,lght) {
var i, j, fn, v, p=new Array(); // vertice & projection arrays
var z=new Array();
for(i=0;i<this.f.length;i++) { // loop through faces
v=this.f[i].v;
for(j=0;j<3;j++) { p[j]=this.v[v[j]].p; }
for(j=0;j<3;j++) { z[j]=this.v[v[j]].t.z; }
if (((p[1].x-p[0].x)*(p[2].y-p[0].y))<((p[2].x-p[0].x)*(p[1].y-p[0].y))) {
this.f[i].d=true;
fn=S_faceNormal(this.v[v[0]].t, this.v[v[1]].t, this.v[v[2]].t);
this.f[i].b=S_faceIntensity(fn,lght);
tr.push(new S_triangle(fn,this.f[i].b,p.slice(),this.f[i].c,z));
} else { this.f[i].d=false; }
}
}
// normal, brightness, array of 2D projection coordinates, and z depth
function S_triangle(fn,b,p,c,z) {
this.fn=fn; this.b=b; this.p=p; this.z=z; this.c=c;
}
function S_faceNormal(a,b,c){
var cr=S_cross(S_subVec3D(b,a), S_subVec3D(b,c));
return S_normalizeVec3D(cr);
}
function S_faceIntensity(fn,lght) {
var i=S_dotVec3D(fn,lght); return (i>0)?i:0;
}
function S_divColor(c,lc,b) { // c:array of colors
var i, clr=new Array();
for(i=0;i<3;i++) clr[i]=Math.floor(c[i]+(lc[i]-c[i]+1)*b);
for(i=0;i<3;i++) if (clr[i]>lc[i]) { clr[i]=lc[i]; }
return S_rgbColor(clr[0],clr[1],clr[2]);
}
function S_sameColor(a,b) {
for(var i=0;i<3;i++) { if(a[i]!=b[i]) return false; }
return true;
}
function S_setupBuffer(scn,p,c) {
// temp, counters, min, max, scanline, vertice & slope arrays
var t,i,j,xmin=new Array(),xmax=new Array(),sl;
var v=new Array(), m=new Array();
p.sort(function(a,b) { return a.y-b.y; } );
for(i=0;i<3;i++) p[i].y=Math.floor(p[i].y);
v[0]=S_subVec2D(p[1],p[0]);
v[1]=S_subVec2D(p[2],p[0]);
v[2]=S_subVec2D(p[2],p[1]);
for(i=0;i<3;i++) { m[i]=(v[i].y!=0)?v[i].x/v[i].y:0; }
for(i=0,sl=scn.t;i<scn.h;i++,sl++) {
xmin[i]=1000;xmax[i]=0;
if((sl>=p[0].y)&&(sl<=p[2].y)) {
xmin[i]=xmax[i]=Math.floor(p[0].x+m[1]*(sl-p[0].y));
}
if((sl>=p[0].y)&&(sl<=p[1].y)) {
t=Math.floor(p[0].x+m[0]*(sl-p[0].y));
if(t<xmin[i]) xmin[i]=Math.floor(t);
else if(t>xmax[i]) xmax[i]=Math.floor(t);
}
if((sl>=p[1].y)&&(sl<=p[2].y)) {
t=Math.floor(p[1].x+m[2]*(sl-p[1].y));
if(t<xmin[i]) xmin[i]=Math.floor(t);
else if(t>xmax[i]) xmax[i]=Math.floor(t);
}
for(j=0;j<scn.w;j++)
if((j>=(xmin[i]-scn.l))&&(j<=(xmax[i]-scn.l))) {
scn.bfr[i][j].d=true; scn.bfr[i][j].c=c;
}
}
}
function S_light() {
this.x=0; this.y=1; this.z=0; this.w=1; // original coordinates
this.t=new S_vec3D(0,1,0); // transformed coordinates
this.tm=new S_matrix();
}
S_scene.prototype.S_adjustLight=function() {
var m=this.lght.tm, l=this.lght;
l.t.x=l.x*m[0]+l.y*m[4]+ l.z*m[8]+l.w*m[12];
l.t.y=l.x*m[1]+l.y*m[5]+ l.z*m[9]+l.w*m[13];
l.t.z=l.x*m[2]+l.y*m[6]+ l.z*m[10]+l.w*m[14];
l.t=S_normalizeVec3D(l.t);
}
S_scene.prototype.S_lightRotateX=function(a) {
S_rotate(this.lght.tm,"x",a*=S_deg2Rad);
}
S_scene.prototype.S_lightRotateY=function(a) {
S_rotate(this.lght.tm,"y",a*=S_deg2Rad);
}
S_scene.prototype.S_lightRotateZ=function(a) {
S_rotate(this.lght.tm,"z",a*=S_deg2Rad);
}
S_scene.prototype.S_clearBuffer=function() {
for(var i=0;i<this.h;i++)
for(var j=0;j<this.w;j++) this.bfr[i][j].d=false;
}
function S_divString(b,t,l,h,w) {
var s='<div style="background-color:'+b+';position:absolute;';
s+='top:'+t+'px;left:'+l+'px;height:'+h+'px;width:'+w;
return s+'px;font-size:0;visibility:visible"></div>';
}
function S_writeInnerHTML(id,text) {
document.getElementById(id).innerHTML = text;
}
</script>
</head>
<body>
<div class="z1" id="graphicsDiv">Text to be replaced with graphics.</div>
<script type="text/javascript">
if(S_checkBrowser()) {
var intrvl;
// Create a new scene with parameters for
// div id, left, top, width, height, and camera distance
var scn=new S_scene("graphicsDiv",75,25,100,100,300);
scn.S_pixelSize(3); // set scene pixel size
var c=S_rgbColor(0,0,127); // color
var c2=S_rgbColor(0,127,127); // color
var m=new S_cube(18,c); // model
m.S_faceColor(4,c2);
m.S_faceColor(5,c2);
m.S_scaleX(2.5); // scale model along x axis
scn.S_models(m); // add model(s) to scene
scn.S_lightRotateX(-25); // adjust light
function r(){ // rotation function
m.S_rotateX(11); // rotate model around y axis
m.S_rotateY(5); // rotate model around y axis
m.S_rotateZ(7); // rotate model around z axis
scn.S_display(); // display scene
} // end rotation function
intrvl=setInterval('r();',75);
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,82 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla PGO Input.
#
# The Initial Developer of the Original Code is
# The Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2008
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Robert Sayre <sayrer@gmail.com>
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_PROFILE_DIR = $(DEPTH)/_profile/pgo/js-input
_PGO_FILES = \
3d-cube.html \
3d-morph.html \
3d-raytrace.html \
3d-thingy.html \
access-binary-trees.html \
access-fannkuch.html \
access-nbody.html \
access-nsieve.html \
bitops-3bit-bits-in-byte.html \
bitops-bits-in-byte.html \
bitops-bitwise-and.html \
bitops-nsieve-bits.html \
controlflow-recursive.html \
crypto-aes.html \
crypto-md5.html \
crypto-sha1.html \
crypto-otp.html \
date-format-tofte.html \
date-format-xparb.html \
math-cordic.html \
math-partial-sums.html \
math-spectral-norm.html \
regexp-dna.html \
string-base64.html \
string-fasta.html \
string-tagcloud.html \
string-unpack-code.html \
string-validate-input.html \
key.gif \
valid-xhtml10.png \
$(NULL)
libs:: $(_PGO_FILES)
$(INSTALL) $^ $(_PROFILE_DIR)

Просмотреть файл

@ -0,0 +1,100 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider access-binary-trees</title>
</head>
<body>
<h3>access-binary-trees</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
/* The Great Computer Language Shootout
http://shootout.alioth.debian.org/
contributed by Isaac Gouy */
function TreeNode(left,right,item){
this.left = left;
this.right = right;
this.item = item;
}
TreeNode.prototype.itemCheck = function(){
if (this.left==null) return this.item;
else return this.item + this.left.itemCheck() - this.right.itemCheck();
}
function bottomUpTree(item,depth){
if (depth>0){
return new TreeNode(
bottomUpTree(2*item-1, depth-1)
,bottomUpTree(2*item, depth-1)
,item
);
}
else {
return new TreeNode(null,null,item);
}
}
var ret;
for ( var n = 4; n <= 7; n += 1 ) {
var minDepth = 4;
var maxDepth = Math.max(minDepth + 2, n);
var stretchDepth = maxDepth + 1;
var check = bottomUpTree(0,stretchDepth).itemCheck();
var longLivedTree = bottomUpTree(0,maxDepth);
for (var depth=minDepth; depth<=maxDepth; depth+=2){
var iterations = 1 << (maxDepth - depth + minDepth);
check = 0;
for (var i=1; i<=iterations; i++){
check += bottomUpTree(i,depth).itemCheck();
check += bottomUpTree(-i,depth).itemCheck();
}
}
ret = longLivedTree.itemCheck();
}
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,116 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider access-fannkuch</title>
</head>
<body>
<h3>access-fannkuch</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
/* The Great Computer Language Shootout
http://shootout.alioth.debian.org/
contributed by Isaac Gouy */
function fannkuch(n) {
var check = 0;
var perm = Array(n);
var perm1 = Array(n);
var count = Array(n);
var maxPerm = Array(n);
var maxFlipsCount = 0;
var m = n - 1;
for (var i = 0; i < n; i++) perm1[i] = i;
var r = n;
while (true) {
// write-out the first 30 permutations
if (check < 30){
var s = "";
for(var i=0; i<n; i++) s += (perm1[i]+1).toString();
check++;
}
while (r != 1) { count[r - 1] = r; r--; }
if (!(perm1[0] == 0 || perm1[m] == m)) {
for (var i = 0; i < n; i++) perm[i] = perm1[i];
var flipsCount = 0;
var k;
while (!((k = perm[0]) == 0)) {
var k2 = (k + 1) >> 1;
for (var i = 0; i < k2; i++) {
var temp = perm[i]; perm[i] = perm[k - i]; perm[k - i] = temp;
}
flipsCount++;
}
if (flipsCount > maxFlipsCount) {
maxFlipsCount = flipsCount;
for (var i = 0; i < n; i++) maxPerm[i] = perm1[i];
}
}
while (true) {
if (r == n) return maxFlipsCount;
var perm0 = perm1[0];
var i = 0;
while (i < r) {
var j = i + 1;
perm1[i] = perm1[j];
i = j;
}
perm1[r] = perm0;
count[r] = count[r] - 1;
if (count[r] > 0) break;
r++;
}
}
}
var n = 8;
var ret = fannkuch(n);
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,219 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider access-nbody</title>
</head>
<body>
<h3>access-nbody</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
/* The Great Computer Language Shootout
http://shootout.alioth.debian.org/
contributed by Isaac Gouy */
var PI = 3.141592653589793;
var SOLAR_MASS = 4 * PI * PI;
var DAYS_PER_YEAR = 365.24;
function Body(x,y,z,vx,vy,vz,mass){
this.x = x;
this.y = y;
this.z = z;
this.vx = vx;
this.vy = vy;
this.vz = vz;
this.mass = mass;
}
Body.prototype.offsetMomentum = function(px,py,pz) {
this.vx = -px / SOLAR_MASS;
this.vy = -py / SOLAR_MASS;
this.vz = -pz / SOLAR_MASS;
return this;
}
function Jupiter(){
return new Body(
4.84143144246472090e+00,
-1.16032004402742839e+00,
-1.03622044471123109e-01,
1.66007664274403694e-03 * DAYS_PER_YEAR,
7.69901118419740425e-03 * DAYS_PER_YEAR,
-6.90460016972063023e-05 * DAYS_PER_YEAR,
9.54791938424326609e-04 * SOLAR_MASS
);
}
function Saturn(){
return new Body(
8.34336671824457987e+00,
4.12479856412430479e+00,
-4.03523417114321381e-01,
-2.76742510726862411e-03 * DAYS_PER_YEAR,
4.99852801234917238e-03 * DAYS_PER_YEAR,
2.30417297573763929e-05 * DAYS_PER_YEAR,
2.85885980666130812e-04 * SOLAR_MASS
);
}
function Uranus(){
return new Body(
1.28943695621391310e+01,
-1.51111514016986312e+01,
-2.23307578892655734e-01,
2.96460137564761618e-03 * DAYS_PER_YEAR,
2.37847173959480950e-03 * DAYS_PER_YEAR,
-2.96589568540237556e-05 * DAYS_PER_YEAR,
4.36624404335156298e-05 * SOLAR_MASS
);
}
function Neptune(){
return new Body(
1.53796971148509165e+01,
-2.59193146099879641e+01,
1.79258772950371181e-01,
2.68067772490389322e-03 * DAYS_PER_YEAR,
1.62824170038242295e-03 * DAYS_PER_YEAR,
-9.51592254519715870e-05 * DAYS_PER_YEAR,
5.15138902046611451e-05 * SOLAR_MASS
);
}
function Sun(){
return new Body(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SOLAR_MASS);
}
function NBodySystem(bodies){
this.bodies = bodies;
var px = 0.0;
var py = 0.0;
var pz = 0.0;
var size = this.bodies.length;
for (var i=0; i<size; i++){
var b = this.bodies[i];
var m = b.mass;
px += b.vx * m;
py += b.vy * m;
pz += b.vz * m;
}
this.bodies[0].offsetMomentum(px,py,pz);
}
NBodySystem.prototype.advance = function(dt){
var dx, dy, dz, distance, mag;
var size = this.bodies.length;
for (var i=0; i<size; i++) {
var bodyi = this.bodies[i];
for (var j=i+1; j<size; j++) {
var bodyj = this.bodies[j];
dx = bodyi.x - bodyj.x;
dy = bodyi.y - bodyj.y;
dz = bodyi.z - bodyj.z;
distance = Math.sqrt(dx*dx + dy*dy + dz*dz);
mag = dt / (distance * distance * distance);
bodyi.vx -= dx * bodyj.mass * mag;
bodyi.vy -= dy * bodyj.mass * mag;
bodyi.vz -= dz * bodyj.mass * mag;
bodyj.vx += dx * bodyi.mass * mag;
bodyj.vy += dy * bodyi.mass * mag;
bodyj.vz += dz * bodyi.mass * mag;
}
}
for (var i=0; i<size; i++) {
var body = this.bodies[i];
body.x += dt * body.vx;
body.y += dt * body.vy;
body.z += dt * body.vz;
}
}
NBodySystem.prototype.energy = function(){
var dx, dy, dz, distance;
var e = 0.0;
var size = this.bodies.length;
for (var i=0; i<size; i++) {
var bodyi = this.bodies[i];
e += 0.5 * bodyi.mass *
( bodyi.vx * bodyi.vx
+ bodyi.vy * bodyi.vy
+ bodyi.vz * bodyi.vz );
for (var j=i+1; j<size; j++) {
var bodyj = this.bodies[j];
dx = bodyi.x - bodyj.x;
dy = bodyi.y - bodyj.y;
dz = bodyi.z - bodyj.z;
distance = Math.sqrt(dx*dx + dy*dy + dz*dz);
e -= (bodyi.mass * bodyj.mass) / distance;
}
}
return e;
}
var ret;
for ( var n = 3; n <= 24; n *= 2 ) {
(function(){
var bodies = new NBodySystem( Array(
Sun(),Jupiter(),Saturn(),Uranus(),Neptune()
));
var max = n * 100;
ret = bodies.energy();
for (var i=0; i<max; i++){
bodies.advance(0.01);
}
ret = bodies.energy();
})();
}
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,88 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider access-nsieve</title>
</head>
<body>
<h3>access-nsieve</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
// The Great Computer Language Shootout
// http://shootout.alioth.debian.org/
//
// modified by Isaac Gouy
function pad(number,width){
var s = number.toString();
var prefixWidth = width - s.length;
if (prefixWidth>0){
for (var i=1; i<=prefixWidth; i++) s = " " + s;
}
return s;
}
function nsieve(m, isPrime){
var i, k, count;
for (i=2; i<=m; i++) { isPrime[i] = true; }
count = 0;
for (i=2; i<=m; i++){
if (isPrime[i]) {
for (k=i+i; k<=m; k+=i) isPrime[k] = false;
count++;
}
}
return count;
}
function sieve() {
for (var i = 1; i <= 3; i++ ) {
var m = (1<<i)*10000;
var flags = Array(m+1);
nsieve(m, flags);
}
}
sieve();
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,82 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider bitops-3bit-bits-in-byte</title>
</head>
<body>
<h3>bitops-3bit-bits-in-byte</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
// Copyright (c) 2004 by Arthur Langereis (arthur_ext at domain xfinitegames, tld com
// 1 op = 6 ANDs, 3 SHRs, 3 SHLs, 4 assigns, 2 ADDs
// O(1)
function fast3bitlookup(b) {
var c, bi3b = 0xE994; // 0b1110 1001 1001 0100; // 3 2 2 1 2 1 1 0
c = 3 & (bi3b >> ((b << 1) & 14));
c += 3 & (bi3b >> ((b >> 2) & 14));
c += 3 & (bi3b >> ((b >> 5) & 6));
return c;
/*
lir4,0xE994; 9 instructions, no memory access, minimal register dependence, 6 shifts, 2 adds, 1 inline assign
rlwinmr5,r3,1,28,30
rlwinmr6,r3,30,28,30
rlwinmr7,r3,27,29,30
rlwnmr8,r4,r5,30,31
rlwnmr9,r4,r6,30,31
rlwnmr10,r4,r7,30,31
addr3,r8,r9
addr3,r3,r10
*/
}
function TimeFunc(func) {
var x, y, t;
for(var x=0; x<500; x++)
for(var y=0; y<256; y++) func(y);
}
TimeFunc(fast3bitlookup);
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,72 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider bitops-bits-in-byte</title>
</head>
<body>
<h3>bitops-bits-in-byte</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
// Copyright (c) 2004 by Arthur Langereis (arthur_ext at domain xfinitegames, tld com)
// 1 op = 2 assigns, 16 compare/branches, 8 ANDs, (0-8) ADDs, 8 SHLs
// O(n)
function bitsinbyte(b) {
var m = 1, c = 0;
while(m<0x100) {
if(b & m) c++;
m <<= 1;
}
return c;
}
function TimeFunc(func) {
var x, y, t;
for(var x=0; x<350; x++)
for(var y=0; y<256; y++) func(y);
}
TimeFunc(bitsinbyte);
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,78 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider bitops-bitwise-and</title>
</head>
<body>
<h3>bitops-bitwise-and</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
bitwiseAndValue = 4294967296;
for (var i = 0; i < 600000; i++)
bitwiseAndValue = bitwiseAndValue & i;
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,82 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider bitops-nsieve-bits</title>
</head>
<body>
<h3>bitops-nsieve-bits</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
// The Great Computer Language Shootout
// http://shootout.alioth.debian.org
//
// Contributed by Ian Osgood
function pad(n,width) {
var s = n.toString();
while (s.length < width) s = ' ' + s;
return s;
}
function primes(isPrime, n) {
var i, count = 0, m = 10000<<n, size = m+31>>5;
for (i=0; i<size; i++) isPrime[i] = 0xffffffff;
for (i=2; i<m; i++)
if (isPrime[i>>5] & 1<<(i&31)) {
for (var j=i+i; j<m; j+=i)
isPrime[j>>5] &= ~(1<<(j&31));
count++;
}
}
function sieve() {
for (var i = 4; i <= 4; i++) {
var isPrime = new Array((10000<<i)+31>>5);
primes(isPrime, i);
}
}
sieve();
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,75 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider controlflow-recursive</title>
</head>
<body>
<h3>controlflow-recursive</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
// The Computer Language Shootout
// http://shootout.alioth.debian.org/
// contributed by Isaac Gouy
function ack(m,n){
if (m==0) { return n+1; }
if (n==0) { return ack(m-1,1); }
return ack(m-1, ack(m,n-1) );
}
function fib(n) {
if (n < 2){ return 1; }
return fib(n-2) + fib(n-1);
}
function tak(x,y,z) {
if (y >= x) return z;
return tak(tak(x-1,y,z), tak(y-1,z,x), tak(z-1,x,y));
}
for ( var i = 3; i <= 5; i++ ) {
ack(3,i);
fib(17.0+i);
tak(3*i+3,2*i+2,i+1);
}
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,472 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider crypto-aes</title>
</head>
<body>
<h3>crypto-aes</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*
* AES Cipher function: encrypt 'input' with Rijndael algorithm
*
* takes byte-array 'input' (16 bytes)
* 2D byte-array key schedule 'w' (Nr+1 x Nb bytes)
*
* applies Nr rounds (10/12/14) using key schedule w for 'add round key' stage
*
* returns byte-array encrypted value (16 bytes)
*/
function Cipher(input, w) { // main Cipher function [§5.1]
var Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
var Nr = w.length/Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys
var state = [[],[],[],[]]; // initialise 4xNb byte-array 'state' with input [§3.4]
for (var i=0; i<4*Nb; i++) state[i%4][Math.floor(i/4)] = input[i];
state = AddRoundKey(state, w, 0, Nb);
for (var round=1; round<Nr; round++) {
state = SubBytes(state, Nb);
state = ShiftRows(state, Nb);
state = MixColumns(state, Nb);
state = AddRoundKey(state, w, round, Nb);
}
state = SubBytes(state, Nb);
state = ShiftRows(state, Nb);
state = AddRoundKey(state, w, Nr, Nb);
var output = new Array(4*Nb); // convert state to 1-d array before returning [§3.4]
for (var i=0; i<4*Nb; i++) output[i] = state[i%4][Math.floor(i/4)];
return output;
}
function SubBytes(s, Nb) { // apply SBox to state S [§5.1.1]
for (var r=0; r<4; r++) {
for (var c=0; c<Nb; c++) s[r][c] = Sbox[s[r][c]];
}
return s;
}
function ShiftRows(s, Nb) { // shift row r of state S left by r bytes [§5.1.2]
var t = new Array(4);
for (var r=1; r<4; r++) {
for (var c=0; c<4; c++) t[c] = s[r][(c+r)%Nb]; // shift into temp copy
for (var c=0; c<4; c++) s[r][c] = t[c]; // and copy back
} // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES):
return s; // see fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.311.pdf
}
function MixColumns(s, Nb) { // combine bytes of each col of state S [§5.1.3]
for (var c=0; c<4; c++) {
var a = new Array(4); // 'a' is a copy of the current column from 's'
var b = new Array(4); // 'b' is a•{02} in GF(2^8)
for (var i=0; i<4; i++) {
a[i] = s[i][c];
b[i] = s[i][c]&0x80 ? s[i][c]<<1 ^ 0x011b : s[i][c]<<1;
}
// a[n] ^ b[n] is a•{03} in GF(2^8)
s[0][c] = b[0] ^ a[1] ^ b[1] ^ a[2] ^ a[3]; // 2*a0 + 3*a1 + a2 + a3
s[1][c] = a[0] ^ b[1] ^ a[2] ^ b[2] ^ a[3]; // a0 * 2*a1 + 3*a2 + a3
s[2][c] = a[0] ^ a[1] ^ b[2] ^ a[3] ^ b[3]; // a0 + a1 + 2*a2 + 3*a3
s[3][c] = a[0] ^ b[0] ^ a[1] ^ a[2] ^ b[3]; // 3*a0 + a1 + a2 + 2*a3
}
return s;
}
function AddRoundKey(state, w, rnd, Nb) { // xor Round Key into state S [§5.1.4]
for (var r=0; r<4; r++) {
for (var c=0; c<Nb; c++) state[r][c] ^= w[rnd*4+c][r];
}
return state;
}
function KeyExpansion(key) { // generate Key Schedule (byte-array Nr+1 x Nb) from Key [§5.2]
var Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
var Nk = key.length/4 // key length (in words): 4/6/8 for 128/192/256-bit keys
var Nr = Nk + 6; // no of rounds: 10/12/14 for 128/192/256-bit keys
var w = new Array(Nb*(Nr+1));
var temp = new Array(4);
for (var i=0; i<Nk; i++) {
var r = [key[4*i], key[4*i+1], key[4*i+2], key[4*i+3]];
w[i] = r;
}
for (var i=Nk; i<(Nb*(Nr+1)); i++) {
w[i] = new Array(4);
for (var t=0; t<4; t++) temp[t] = w[i-1][t];
if (i % Nk == 0) {
temp = SubWord(RotWord(temp));
for (var t=0; t<4; t++) temp[t] ^= Rcon[i/Nk][t];
} else if (Nk > 6 && i%Nk == 4) {
temp = SubWord(temp);
}
for (var t=0; t<4; t++) w[i][t] = w[i-Nk][t] ^ temp[t];
}
return w;
}
function SubWord(w) { // apply SBox to 4-byte word w
for (var i=0; i<4; i++) w[i] = Sbox[w[i]];
return w;
}
function RotWord(w) { // rotate 4-byte word w left by one byte
w[4] = w[0];
for (var i=0; i<4; i++) w[i] = w[i+1];
return w;
}
// Sbox is pre-computed multiplicative inverse in GF(2^8) used in SubBytes and KeyExpansion [§5.1.1]
var Sbox = [0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76,
0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0,
0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15,
0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a,0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75,
0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84,
0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b,0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf,
0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85,0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8,
0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5,0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2,
0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17,0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73,
0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88,0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb,
0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c,0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79,
0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9,0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08,
0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6,0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a,
0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e,0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e,
0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf,
0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16];
// Rcon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [§5.2]
var Rcon = [ [0x00, 0x00, 0x00, 0x00],
[0x01, 0x00, 0x00, 0x00],
[0x02, 0x00, 0x00, 0x00],
[0x04, 0x00, 0x00, 0x00],
[0x08, 0x00, 0x00, 0x00],
[0x10, 0x00, 0x00, 0x00],
[0x20, 0x00, 0x00, 0x00],
[0x40, 0x00, 0x00, 0x00],
[0x80, 0x00, 0x00, 0x00],
[0x1b, 0x00, 0x00, 0x00],
[0x36, 0x00, 0x00, 0x00] ];
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*
* Use AES to encrypt 'plaintext' with 'password' using 'nBits' key, in 'Counter' mode of operation
* - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
* for each block
* - outputblock = cipher(counter, key)
* - cipherblock = plaintext xor outputblock
*/
function AESEncryptCtr(plaintext, password, nBits) {
if (!(nBits==128 || nBits==192 || nBits==256)) return ''; // standard allows 128/192/256 bit keys
// for this example script, generate the key by applying Cipher to 1st 16/24/32 chars of password;
// for real-world applications, a more secure approach would be to hash the password e.g. with SHA-1
var nBytes = nBits/8; // no bytes in key
var pwBytes = new Array(nBytes);
for (var i=0; i<nBytes; i++) pwBytes[i] = password.charCodeAt(i) & 0xff;
var key = Cipher(pwBytes, KeyExpansion(pwBytes));
key = key.concat(key.slice(0, nBytes-16)); // key is now 16/24/32 bytes long
// initialise counter block (NIST SP800-38A §B.2): millisecond time-stamp for nonce in 1st 8 bytes,
// block counter in 2nd 8 bytes
var blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
var counterBlock = new Array(blockSize); // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
var nonce = (new Date()).getTime(); // milliseconds since 1-Jan-1970
// encode nonce in two stages to cater for JavaScript 32-bit limit on bitwise ops
for (var i=0; i<4; i++) counterBlock[i] = (nonce >>> i*8) & 0xff;
for (var i=0; i<4; i++) counterBlock[i+4] = (nonce/0x100000000 >>> i*8) & 0xff;
// generate key schedule - an expansion of the key into distinct Key Rounds for each round
var keySchedule = KeyExpansion(key);
var blockCount = Math.ceil(plaintext.length/blockSize);
var ciphertext = new Array(blockCount); // ciphertext as array of strings
for (var b=0; b<blockCount; b++) {
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
// again done in two stages for 32-bit ops
for (var c=0; c<4; c++) counterBlock[15-c] = (b >>> c*8) & 0xff;
for (var c=0; c<4; c++) counterBlock[15-c-4] = (b/0x100000000 >>> c*8)
var cipherCntr = Cipher(counterBlock, keySchedule); // -- encrypt counter block --
// calculate length of final block:
var blockLength = b<blockCount-1 ? blockSize : (plaintext.length-1)%blockSize+1;
var ct = '';
for (var i=0; i<blockLength; i++) { // -- xor plaintext with ciphered counter byte-by-byte --
var plaintextByte = plaintext.charCodeAt(b*blockSize+i);
var cipherByte = plaintextByte ^ cipherCntr[i];
ct += String.fromCharCode(cipherByte);
}
// ct is now ciphertext for this block
ciphertext[b] = escCtrlChars(ct); // escape troublesome characters in ciphertext
}
// convert the nonce to a string to go on the front of the ciphertext
var ctrTxt = '';
for (var i=0; i<8; i++) ctrTxt += String.fromCharCode(counterBlock[i]);
ctrTxt = escCtrlChars(ctrTxt);
// use '-' to separate blocks, use Array.join to concatenate arrays of strings for efficiency
return ctrTxt + '-' + ciphertext.join('-');
}
/*
* Use AES to decrypt 'ciphertext' with 'password' using 'nBits' key, in Counter mode of operation
*
* for each block
* - outputblock = cipher(counter, key)
* - cipherblock = plaintext xor outputblock
*/
function AESDecryptCtr(ciphertext, password, nBits) {
if (!(nBits==128 || nBits==192 || nBits==256)) return ''; // standard allows 128/192/256 bit keys
var nBytes = nBits/8; // no bytes in key
var pwBytes = new Array(nBytes);
for (var i=0; i<nBytes; i++) pwBytes[i] = password.charCodeAt(i) & 0xff;
var pwKeySchedule = KeyExpansion(pwBytes);
var key = Cipher(pwBytes, pwKeySchedule);
key = key.concat(key.slice(0, nBytes-16)); // key is now 16/24/32 bytes long
var keySchedule = KeyExpansion(key);
ciphertext = ciphertext.split('-'); // split ciphertext into array of block-length strings
// recover nonce from 1st element of ciphertext
var blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
var counterBlock = new Array(blockSize);
var ctrTxt = unescCtrlChars(ciphertext[0]);
for (var i=0; i<8; i++) counterBlock[i] = ctrTxt.charCodeAt(i);
var plaintext = new Array(ciphertext.length-1);
for (var b=1; b<ciphertext.length; b++) {
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
for (var c=0; c<4; c++) counterBlock[15-c] = ((b-1) >>> c*8) & 0xff;
for (var c=0; c<4; c++) counterBlock[15-c-4] = ((b/0x100000000-1) >>> c*8) & 0xff;
var cipherCntr = Cipher(counterBlock, keySchedule); // encrypt counter block
ciphertext[b] = unescCtrlChars(ciphertext[b]);
var pt = '';
for (var i=0; i<ciphertext[b].length; i++) {
// -- xor plaintext with ciphered counter byte-by-byte --
var ciphertextByte = ciphertext[b].charCodeAt(i);
var plaintextByte = ciphertextByte ^ cipherCntr[i];
pt += String.fromCharCode(plaintextByte);
}
// pt is now plaintext for this block
plaintext[b-1] = pt; // b-1 'cos no initial nonce block in plaintext
}
return plaintext.join('');
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function escCtrlChars(str) { // escape control chars which might cause problems handling ciphertext
return str.replace(/[\0\t\n\v\f\r\xa0'"!-]/g, function(c) { return '!' + c.charCodeAt(0) + '!'; });
} // \xa0 to cater for bug in Firefox; include '-' to leave it free for use as a block marker
function unescCtrlChars(str) { // unescape potentially problematic control characters
return str.replace(/!\d\d?\d?!/g, function(c) { return String.fromCharCode(c.slice(1,-1)); });
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*
* if escCtrlChars()/unescCtrlChars() still gives problems, use encodeBase64()/decodeBase64() instead
*/
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function encodeBase64(str) { // http://tools.ietf.org/html/rfc4648
var o1, o2, o3, h1, h2, h3, h4, bits, i=0, enc='';
str = encodeUTF8(str); // encode multi-byte chars into UTF-8 for byte-array
do { // pack three octets into four hexets
o1 = str.charCodeAt(i++);
o2 = str.charCodeAt(i++);
o3 = str.charCodeAt(i++);
bits = o1<<16 | o2<<8 | o3;
h1 = bits>>18 & 0x3f;
h2 = bits>>12 & 0x3f;
h3 = bits>>6 & 0x3f;
h4 = bits & 0x3f;
// end of string? index to '=' in b64
if (isNaN(o3)) h4 = 64;
if (isNaN(o2)) h3 = 64;
// use hexets to index into b64, and append result to encoded string
enc += b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
} while (i < str.length);
return enc;
}
function decodeBase64(str) {
var o1, o2, o3, h1, h2, h3, h4, bits, i=0, enc='';
do { // unpack four hexets into three octets using index points in b64
h1 = b64.indexOf(str.charAt(i++));
h2 = b64.indexOf(str.charAt(i++));
h3 = b64.indexOf(str.charAt(i++));
h4 = b64.indexOf(str.charAt(i++));
bits = h1<<18 | h2<<12 | h3<<6 | h4;
o1 = bits>>16 & 0xff;
o2 = bits>>8 & 0xff;
o3 = bits & 0xff;
if (h3 == 64) enc += String.fromCharCode(o1);
else if (h4 == 64) enc += String.fromCharCode(o1, o2);
else enc += String.fromCharCode(o1, o2, o3);
} while (i < str.length);
return decodeUTF8(enc); // decode UTF-8 byte-array back to Unicode
}
function encodeUTF8(str) { // encode multi-byte string into utf-8 multiple single-byte characters
str = str.replace(
/[\u0080-\u07ff]/g, // U+0080 - U+07FF = 2-byte chars
function(c) {
var cc = c.charCodeAt(0);
return String.fromCharCode(0xc0 | cc>>6, 0x80 | cc&0x3f); }
);
str = str.replace(
/[\u0800-\uffff]/g, // U+0800 - U+FFFF = 3-byte chars
function(c) {
var cc = c.charCodeAt(0);
return String.fromCharCode(0xe0 | cc>>12, 0x80 | cc>>6&0x3F, 0x80 | cc&0x3f); }
);
return str;
}
function decodeUTF8(str) { // decode utf-8 encoded string back into multi-byte characters
str = str.replace(
/[\u00c0-\u00df][\u0080-\u00bf]/g, // 2-byte chars
function(c) {
var cc = (c.charCodeAt(0)&0x1f)<<6 | c.charCodeAt(1)&0x3f;
return String.fromCharCode(cc); }
);
str = str.replace(
/[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g, // 3-byte chars
function(c) {
var cc = (c.charCodeAt(0)&0x0f)<<12 | (c.charCodeAt(1)&0x3f<<6) | c.charCodeAt(2)&0x3f;
return String.fromCharCode(cc); }
);
return str;
}
function byteArrayToHexStr(b) { // convert byte array to hex string for displaying test vectors
var s = '';
for (var i=0; i<b.length; i++) s += b[i].toString(16) + ' ';
return s;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
var plainText = "ROMEO: But, soft! what light through yonder window breaks?\n\
It is the east, and Juliet is the sun.\n\
Arise, fair sun, and kill the envious moon,\n\
Who is already sick and pale with grief,\n\
That thou her maid art far more fair than she:\n\
Be not her maid, since she is envious;\n\
Her vestal livery is but sick and green\n\
And none but fools do wear it; cast it off.\n\
It is my lady, O, it is my love!\n\
O, that she knew she were!\n\
She speaks yet she says nothing: what of that?\n\
Her eye discourses; I will answer it.\n\
I am too bold, 'tis not to me she speaks:\n\
Two of the fairest stars in all the heaven,\n\
Having some business, do entreat her eyes\n\
To twinkle in their spheres till they return.\n\
What if her eyes were there, they in her head?\n\
The brightness of her cheek would shame those stars,\n\
As daylight doth a lamp; her eyes in heaven\n\
Would through the airy region stream so bright\n\
That birds would sing and think it were not night.\n\
See, how she leans her cheek upon her hand!\n\
O, that I were a glove upon that hand,\n\
That I might touch that cheek!\n\
JULIET: Ay me!\n\
ROMEO: She speaks:\n\
O, speak again, bright angel! for thou art\n\
As glorious to this night, being o'er my head\n\
As is a winged messenger of heaven\n\
Unto the white-upturned wondering eyes\n\
Of mortals that fall back to gaze on him\n\
When he bestrides the lazy-pacing clouds\n\
And sails upon the bosom of the air.";
var password = "O Romeo, Romeo! wherefore art thou Romeo?";
var cipherText = AESEncryptCtr(plainText, password, 256);
var decryptedText = AESDecryptCtr(cipherText, password, 256);
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,336 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider crypto-md5</title>
</head>
<body>
<h3>crypto-md5</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for more info.
*/
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
/*
* Perform a simple self-test to see if the VM is working
*/
function md5_vm_test()
{
return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length
*/
function core_md5(x, len)
{
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for(var i = 0; i < x.length; i += 16)
{
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return Array(a, b, c, d);
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5_cmn(q, a, b, x, s, t)
{
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t)
{
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t)
{
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t)
{
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t)
{
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
/*
* Calculate the HMAC-MD5, of a key and some data
*/
function core_hmac_md5(key, data)
{
var bkey = str2binl(key);
if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
var ipad = Array(16), opad = Array(16);
for(var i = 0; i < 16; i++)
{
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
return core_md5(opad.concat(hash), 512 + 128);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function bit_rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt));
}
/*
* Convert a string to an array of little-endian words
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
*/
function str2binl(str)
{
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz)
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
return bin;
}
/*
* Convert an array of little-endian words to a string
*/
function binl2str(bin)
{
var str = "";
var mask = (1 << chrsz) - 1;
for(var i = 0; i < bin.length * 32; i += chrsz)
str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
return str;
}
/*
* Convert an array of little-endian words to a hex string.
*/
function binl2hex(binarray)
{
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
}
return str;
}
/*
* Convert an array of little-endian words to a base-64 string
*/
function binl2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for(var i = 0; i < binarray.length * 4; i += 3)
{
var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
| (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
| ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
}
}
return str;
}
var plainText = "Rebellious subjects, enemies to peace,\n\
Profaners of this neighbour-stained steel,--\n\
Will they not hear? What, ho! you men, you beasts,\n\
That quench the fire of your pernicious rage\n\
With purple fountains issuing from your veins,\n\
On pain of torture, from those bloody hands\n\
Throw your mistemper'd weapons to the ground,\n\
And hear the sentence of your moved prince.\n\
Three civil brawls, bred of an airy word,\n\
By thee, old Capulet, and Montague,\n\
Have thrice disturb'd the quiet of our streets,\n\
And made Verona's ancient citizens\n\
Cast by their grave beseeming ornaments,\n\
To wield old partisans, in hands as old,\n\
Canker'd with peace, to part your canker'd hate:\n\
If ever you disturb our streets again,\n\
Your lives shall pay the forfeit of the peace.\n\
For this time, all the rest depart away:\n\
You Capulet; shall go along with me:\n\
And, Montague, come you this afternoon,\n\
To know our further pleasure in this case,\n\
To old Free-town, our common judgment-place.\n\
Once more, on pain of death, all men depart."
for (var i = 0; i <4; i++) {
plainText += plainText;
}
var md5Output = hex_md5(plainText);
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,274 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider crypto-sha1</title>
</head>
<body>
<h3>crypto-sha1</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
/*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
* in FIPS PUB 180-1
* Version 2.1a Copyright Paul Johnston 2000 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for details.
*/
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}
function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}
function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}
function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}
function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}
function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}
/*
* Perform a simple self-test to see if the VM is working
*/
function sha1_vm_test()
{
return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";
}
/*
* Calculate the SHA-1 of an array of big-endian words, and a bit length
*/
function core_sha1(x, len)
{
/* append padding */
x[len >> 5] |= 0x80 << (24 - len % 32);
x[((len + 64 >> 9) << 4) + 15] = len;
var w = Array(80);
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
var e = -1009589776;
for(var i = 0; i < x.length; i += 16)
{
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
var olde = e;
for(var j = 0; j < 80; j++)
{
if(j < 16) w[j] = x[i + j];
else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
safe_add(safe_add(e, w[j]), sha1_kt(j)));
e = d;
d = c;
c = rol(b, 30);
b = a;
a = t;
}
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
e = safe_add(e, olde);
}
return Array(a, b, c, d, e);
}
/*
* Perform the appropriate triplet combination function for the current
* iteration
*/
function sha1_ft(t, b, c, d)
{
if(t < 20) return (b & c) | ((~b) & d);
if(t < 40) return b ^ c ^ d;
if(t < 60) return (b & c) | (b & d) | (c & d);
return b ^ c ^ d;
}
/*
* Determine the appropriate additive constant for the current iteration
*/
function sha1_kt(t)
{
return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
(t < 60) ? -1894007588 : -899497514;
}
/*
* Calculate the HMAC-SHA1 of a key and some data
*/
function core_hmac_sha1(key, data)
{
var bkey = str2binb(key);
if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);
var ipad = Array(16), opad = Array(16);
for(var i = 0; i < 16; i++)
{
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
return core_sha1(opad.concat(hash), 512 + 160);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt));
}
/*
* Convert an 8-bit or 16-bit string to an array of big-endian words
* In 8-bit function, characters >255 have their hi-byte silently ignored.
*/
function str2binb(str)
{
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz)
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);
return bin;
}
/*
* Convert an array of big-endian words to a string
*/
function binb2str(bin)
{
var str = "";
var mask = (1 << chrsz) - 1;
for(var i = 0; i < bin.length * 32; i += chrsz)
str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);
return str;
}
/*
* Convert an array of big-endian words to a hex string.
*/
function binb2hex(binarray)
{
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);
}
return str;
}
/*
* Convert an array of big-endian words to a base-64 string
*/
function binb2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for(var i = 0; i < binarray.length * 4; i += 3)
{
var triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16)
| (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )
| ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
}
}
return str;
}
var plainText = "Two households, both alike in dignity,\n\
In fair Verona, where we lay our scene,\n\
From ancient grudge break to new mutiny,\n\
Where civil blood makes civil hands unclean.\n\
From forth the fatal loins of these two foes\n\
A pair of star-cross'd lovers take their life;\n\
Whole misadventured piteous overthrows\n\
Do with their death bury their parents' strife.\n\
The fearful passage of their death-mark'd love,\n\
And the continuance of their parents' rage,\n\
Which, but their children's end, nought could remove,\n\
Is now the two hours' traffic of our stage;\n\
The which if you with patient ears attend,\n\
What here shall miss, our toil shall strive to mend.";
for (var i = 0; i <4; i++) {
plainText += plainText;
}
var sha1Output = hex_sha1(plainText);
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,349 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider date-format-tofte</title>
</head>
<body>
<h3>date-format-tofte</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
function arrayExists(array, x) {
for (var i = 0; i < array.length; i++) {
if (array[i] == x) return true;
}
return false;
}
Date.prototype.formatDate = function (input,time) {
// formatDate :
// a PHP date like function, for formatting date strings
// See: http://www.php.net/date
//
// input : format string
// time : epoch time (seconds, and optional)
//
// if time is not passed, formatting is based on
// the current "this" date object's set time.
//
// supported:
// a, A, B, d, D, F, g, G, h, H, i, j, l (lowercase L), L,
// m, M, n, O, r, s, S, t, U, w, W, y, Y, z
//
// unsupported:
// I (capital i), T, Z
var switches = ["a", "A", "B", "d", "D", "F", "g", "G", "h", "H",
"i", "j", "l", "L", "m", "M", "n", "O", "r", "s",
"S", "t", "U", "w", "W", "y", "Y", "z"];
var daysLong = ["Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"];
var daysShort = ["Sun", "Mon", "Tue", "Wed",
"Thu", "Fri", "Sat"];
var monthsShort = ["Jan", "Feb", "Mar", "Apr",
"May", "Jun", "Jul", "Aug", "Sep",
"Oct", "Nov", "Dec"];
var monthsLong = ["January", "February", "March", "April",
"May", "June", "July", "August", "September",
"October", "November", "December"];
var daysSuffix = ["st", "nd", "rd", "th", "th", "th", "th", // 1st - 7th
"th", "th", "th", "th", "th", "th", "th", // 8th - 14th
"th", "th", "th", "th", "th", "th", "st", // 15th - 21st
"nd", "rd", "th", "th", "th", "th", "th", // 22nd - 28th
"th", "th", "st"]; // 29th - 31st
function a() {
// Lowercase Ante meridiem and Post meridiem
return self.getHours() > 11? "pm" : "am";
}
function A() {
// Uppercase Ante meridiem and Post meridiem
return self.getHours() > 11? "PM" : "AM";
}
function B(){
// Swatch internet time. code simply grabbed from ppk,
// since I was feeling lazy:
// http://www.xs4all.nl/~ppk/js/beat.html
var off = (self.getTimezoneOffset() + 60)*60;
var theSeconds = (self.getHours() * 3600) +
(self.getMinutes() * 60) +
self.getSeconds() + off;
var beat = Math.floor(theSeconds/86.4);
if (beat > 1000) beat -= 1000;
if (beat < 0) beat += 1000;
if ((""+beat).length == 1) beat = "00"+beat;
if ((""+beat).length == 2) beat = "0"+beat;
return beat;
}
function d() {
// Day of the month, 2 digits with leading zeros
return new String(self.getDate()).length == 1?
"0"+self.getDate() : self.getDate();
}
function D() {
// A textual representation of a day, three letters
return daysShort[self.getDay()];
}
function F() {
// A full textual representation of a month
return monthsLong[self.getMonth()];
}
function g() {
// 12-hour format of an hour without leading zeros
return self.getHours() > 12? self.getHours()-12 : self.getHours();
}
function G() {
// 24-hour format of an hour without leading zeros
return self.getHours();
}
function h() {
// 12-hour format of an hour with leading zeros
if (self.getHours() > 12) {
var s = new String(self.getHours()-12);
return s.length == 1?
"0"+ (self.getHours()-12) : self.getHours()-12;
} else {
var s = new String(self.getHours());
return s.length == 1?
"0"+self.getHours() : self.getHours();
}
}
function H() {
// 24-hour format of an hour with leading zeros
return new String(self.getHours()).length == 1?
"0"+self.getHours() : self.getHours();
}
function i() {
// Minutes with leading zeros
return new String(self.getMinutes()).length == 1?
"0"+self.getMinutes() : self.getMinutes();
}
function j() {
// Day of the month without leading zeros
return self.getDate();
}
function l() {
// A full textual representation of the day of the week
return daysLong[self.getDay()];
}
function L() {
// leap year or not. 1 if leap year, 0 if not.
// the logic should match iso's 8601 standard.
var y_ = Y();
if (
(y_ % 4 == 0 && y_ % 100 != 0) ||
(y_ % 4 == 0 && y_ % 100 == 0 && y_ % 400 == 0)
) {
return 1;
} else {
return 0;
}
}
function m() {
// Numeric representation of a month, with leading zeros
return self.getMonth() < 9?
"0"+(self.getMonth()+1) :
self.getMonth()+1;
}
function M() {
// A short textual representation of a month, three letters
return monthsShort[self.getMonth()];
}
function n() {
// Numeric representation of a month, without leading zeros
return self.getMonth()+1;
}
function O() {
// Difference to Greenwich time (GMT) in hours
var os = Math.abs(self.getTimezoneOffset());
var h = ""+Math.floor(os/60);
var m = ""+(os%60);
h.length == 1? h = "0"+h:1;
m.length == 1? m = "0"+m:1;
return self.getTimezoneOffset() < 0 ? "+"+h+m : "-"+h+m;
}
function r() {
// RFC 822 formatted date
var r; // result
// Thu , 21 Dec 2000
r = D() + ", " + j() + " " + M() + " " + Y() +
// 16 : 01 : 07 +0200
" " + H() + ":" + i() + ":" + s() + " " + O();
return r;
}
function S() {
// English ordinal suffix for the day of the month, 2 characters
return daysSuffix[self.getDate()-1];
}
function s() {
// Seconds, with leading zeros
return new String(self.getSeconds()).length == 1?
"0"+self.getSeconds() : self.getSeconds();
}
function t() {
// thanks to Matt Bannon for some much needed code-fixes here!
var daysinmonths = [null,31,28,31,30,31,30,31,31,30,31,30,31];
if (L()==1 && n()==2) return 29; // leap day
return daysinmonths[n()];
}
function U() {
// Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
return Math.round(self.getTime()/1000);
}
function W() {
// Weeknumber, as per ISO specification:
// http://www.cl.cam.ac.uk/~mgk25/iso-time.html
// if the day is three days before newyears eve,
// there's a chance it's "week 1" of next year.
// here we check for that.
var beforeNY = 364+L() - z();
var afterNY = z();
var weekday = w()!=0?w()-1:6; // makes sunday (0), into 6.
if (beforeNY <= 2 && weekday <= 2-beforeNY) {
return 1;
}
// similarly, if the day is within threedays of newyears
// there's a chance it belongs in the old year.
var ny = new Date("January 1 " + Y() + " 00:00:00");
var nyDay = ny.getDay()!=0?ny.getDay()-1:6;
if (
(afterNY <= 2) &&
(nyDay >=4) &&
(afterNY >= (6-nyDay))
) {
// Since I'm not sure we can just always return 53,
// i call the function here again, using the last day
// of the previous year, as the date, and then just
// return that week.
var prevNY = new Date("December 31 " + (Y()-1) + " 00:00:00");
return prevNY.formatDate("W");
}
// week 1, is the week that has the first thursday in it.
// note that this value is not zero index.
if (nyDay <= 3) {
// first day of the year fell on a thursday, or earlier.
return 1 + Math.floor( ( z() + nyDay ) / 7 );
} else {
// first day of the year fell on a friday, or later.
return 1 + Math.floor( ( z() - ( 7 - nyDay ) ) / 7 );
}
}
function w() {
// Numeric representation of the day of the week
return self.getDay();
}
function Y() {
// A full numeric representation of a year, 4 digits
// we first check, if getFullYear is supported. if it
// is, we just use that. ppks code is nice, but wont
// work with dates outside 1900-2038, or something like that
if (self.getFullYear) {
var newDate = new Date("January 1 2001 00:00:00 +0000");
var x = newDate .getFullYear();
if (x == 2001) {
// i trust the method now
return self.getFullYear();
}
}
// else, do this:
// codes thanks to ppk:
// http://www.xs4all.nl/~ppk/js/introdate.html
var x = self.getYear();
var y = x % 100;
y += (y < 38) ? 2000 : 1900;
return y;
}
function y() {
// A two-digit representation of a year
var y = Y()+"";
return y.substring(y.length-2,y.length);
}
function z() {
// The day of the year, zero indexed! 0 through 366
var t = new Date("January 1 " + Y() + " 00:00:00");
var diff = self.getTime() - t.getTime();
return Math.floor(diff/1000/60/60/24);
}
var self = this;
if (time) {
// save time
var prevTime = self.getTime();
self.setTime(time);
}
var ia = input.split("");
var ij = 0;
while (ia[ij]) {
if (ia[ij] == "\\") {
// this is our way of allowing users to escape stuff
ia.splice(ij,1);
} else {
if (arrayExists(switches,ia[ij])) {
ia[ij] = eval(ia[ij] + "()");
}
}
ij++;
}
// reset time, back to what it was
if (prevTime) {
self.setTime(prevTime);
}
return ia.join("");
}
var date = new Date("1/1/2007 1:11:11");
for (i = 0; i < 500; ++i) {
var shortFormat = date.formatDate("Y-m-d");
var longFormat = date.formatDate("l, F d, Y g:i:s A");
date.setTime(date.getTime() + 84266956);
}
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,467 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider date-format-xparb</title>
</head>
<body>
<h3>date-format-xparb</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
/*
* Copyright (C) 2004 Baron Schwartz <baron at sequent dot org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, version 2.1.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
Date.parseFunctions = {count:0};
Date.parseRegexes = [];
Date.formatFunctions = {count:0};
Date.prototype.dateFormat = function(format) {
if (Date.formatFunctions[format] == null) {
Date.createNewFormat(format);
}
var func = Date.formatFunctions[format];
return this[func]();
}
Date.createNewFormat = function(format) {
var funcName = "format" + Date.formatFunctions.count++;
Date.formatFunctions[format] = funcName;
var code = "Date.prototype." + funcName + " = function(){return ";
var special = false;
var ch = '';
for (var i = 0; i < format.length; ++i) {
ch = format.charAt(i);
if (!special && ch == "\\") {
special = true;
}
else if (special) {
special = false;
code += "'" + String.escape(ch) + "' + ";
}
else {
code += Date.getFormatCode(ch);
}
}
eval(code.substring(0, code.length - 3) + ";}");
}
Date.getFormatCode = function(character) {
switch (character) {
case "d":
return "String.leftPad(this.getDate(), 2, '0') + ";
case "D":
return "Date.dayNames[this.getDay()].substring(0, 3) + ";
case "j":
return "this.getDate() + ";
case "l":
return "Date.dayNames[this.getDay()] + ";
case "S":
return "this.getSuffix() + ";
case "w":
return "this.getDay() + ";
case "z":
return "this.getDayOfYear() + ";
case "W":
return "this.getWeekOfYear() + ";
case "F":
return "Date.monthNames[this.getMonth()] + ";
case "m":
return "String.leftPad(this.getMonth() + 1, 2, '0') + ";
case "M":
return "Date.monthNames[this.getMonth()].substring(0, 3) + ";
case "n":
return "(this.getMonth() + 1) + ";
case "t":
return "this.getDaysInMonth() + ";
case "L":
return "(this.isLeapYear() ? 1 : 0) + ";
case "Y":
return "this.getFullYear() + ";
case "y":
return "('' + this.getFullYear()).substring(2, 4) + ";
case "a":
return "(this.getHours() < 12 ? 'am' : 'pm') + ";
case "A":
return "(this.getHours() < 12 ? 'AM' : 'PM') + ";
case "g":
return "((this.getHours() %12) ? this.getHours() % 12 : 12) + ";
case "G":
return "this.getHours() + ";
case "h":
return "String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + ";
case "H":
return "String.leftPad(this.getHours(), 2, '0') + ";
case "i":
return "String.leftPad(this.getMinutes(), 2, '0') + ";
case "s":
return "String.leftPad(this.getSeconds(), 2, '0') + ";
case "O":
return "this.getGMTOffset() + ";
case "T":
return "this.getTimezone() + ";
case "Z":
return "(this.getTimezoneOffset() * -60) + ";
default:
return "'" + String.escape(character) + "' + ";
}
}
Date.parseDate = function(input, format) {
if (Date.parseFunctions[format] == null) {
Date.createParser(format);
}
var func = Date.parseFunctions[format];
return Date[func](input);
}
Date.createParser = function(format) {
var funcName = "parse" + Date.parseFunctions.count++;
var regexNum = Date.parseRegexes.length;
var currentGroup = 1;
Date.parseFunctions[format] = funcName;
var code = "Date." + funcName + " = function(input){\n"
+ "var y = -1, m = -1, d = -1, h = -1, i = -1, s = -1;\n"
+ "var d = new Date();\n"
+ "y = d.getFullYear();\n"
+ "m = d.getMonth();\n"
+ "d = d.getDate();\n"
+ "var results = input.match(Date.parseRegexes[" + regexNum + "]);\n"
+ "if (results && results.length > 0) {"
var regex = "";
var special = false;
var ch = '';
for (var i = 0; i < format.length; ++i) {
ch = format.charAt(i);
if (!special && ch == "\\") {
special = true;
}
else if (special) {
special = false;
regex += String.escape(ch);
}
else {
obj = Date.formatCodeToRegex(ch, currentGroup);
currentGroup += obj.g;
regex += obj.s;
if (obj.g && obj.c) {
code += obj.c;
}
}
}
code += "if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n"
+ "{return new Date(y, m, d, h, i, s);}\n"
+ "else if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n"
+ "{return new Date(y, m, d, h, i);}\n"
+ "else if (y > 0 && m >= 0 && d > 0 && h >= 0)\n"
+ "{return new Date(y, m, d, h);}\n"
+ "else if (y > 0 && m >= 0 && d > 0)\n"
+ "{return new Date(y, m, d);}\n"
+ "else if (y > 0 && m >= 0)\n"
+ "{return new Date(y, m);}\n"
+ "else if (y > 0)\n"
+ "{return new Date(y);}\n"
+ "}return null;}";
Date.parseRegexes[regexNum] = new RegExp("^" + regex + "$");
eval(code);
}
Date.formatCodeToRegex = function(character, currentGroup) {
switch (character) {
case "D":
return {g:0,
c:null,
s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};
case "j":
case "d":
return {g:1,
c:"d = parseInt(results[" + currentGroup + "], 10);\n",
s:"(\\d{1,2})"};
case "l":
return {g:0,
c:null,
s:"(?:" + Date.dayNames.join("|") + ")"};
case "S":
return {g:0,
c:null,
s:"(?:st|nd|rd|th)"};
case "w":
return {g:0,
c:null,
s:"\\d"};
case "z":
return {g:0,
c:null,
s:"(?:\\d{1,3})"};
case "W":
return {g:0,
c:null,
s:"(?:\\d{2})"};
case "F":
return {g:1,
c:"m = parseInt(Date.monthNumbers[results[" + currentGroup + "].substring(0, 3)], 10);\n",
s:"(" + Date.monthNames.join("|") + ")"};
case "M":
return {g:1,
c:"m = parseInt(Date.monthNumbers[results[" + currentGroup + "]], 10);\n",
s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};
case "n":
case "m":
return {g:1,
c:"m = parseInt(results[" + currentGroup + "], 10) - 1;\n",
s:"(\\d{1,2})"};
case "t":
return {g:0,
c:null,
s:"\\d{1,2}"};
case "L":
return {g:0,
c:null,
s:"(?:1|0)"};
case "Y":
return {g:1,
c:"y = parseInt(results[" + currentGroup + "], 10);\n",
s:"(\\d{4})"};
case "y":
return {g:1,
c:"var ty = parseInt(results[" + currentGroup + "], 10);\n"
+ "y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",
s:"(\\d{1,2})"};
case "a":
return {g:1,
c:"if (results[" + currentGroup + "] == 'am') {\n"
+ "if (h == 12) { h = 0; }\n"
+ "} else { if (h < 12) { h += 12; }}",
s:"(am|pm)"};
case "A":
return {g:1,
c:"if (results[" + currentGroup + "] == 'AM') {\n"
+ "if (h == 12) { h = 0; }\n"
+ "} else { if (h < 12) { h += 12; }}",
s:"(AM|PM)"};
case "g":
case "G":
case "h":
case "H":
return {g:1,
c:"h = parseInt(results[" + currentGroup + "], 10);\n",
s:"(\\d{1,2})"};
case "i":
return {g:1,
c:"i = parseInt(results[" + currentGroup + "], 10);\n",
s:"(\\d{2})"};
case "s":
return {g:1,
c:"s = parseInt(results[" + currentGroup + "], 10);\n",
s:"(\\d{2})"};
case "O":
return {g:0,
c:null,
s:"[+-]\\d{4}"};
case "T":
return {g:0,
c:null,
s:"[A-Z]{3}"};
case "Z":
return {g:0,
c:null,
s:"[+-]\\d{1,5}"};
default:
return {g:0,
c:null,
s:String.escape(character)};
}
}
Date.prototype.getTimezone = function() {
return this.toString().replace(
/^.*? ([A-Z]{3}) [0-9]{4}.*$/, "$1").replace(
/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, "$1$2$3");
}
Date.prototype.getGMTOffset = function() {
return (this.getTimezoneOffset() > 0 ? "-" : "+")
+ String.leftPad(Math.floor(this.getTimezoneOffset() / 60), 2, "0")
+ String.leftPad(this.getTimezoneOffset() % 60, 2, "0");
}
Date.prototype.getDayOfYear = function() {
var num = 0;
Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
for (var i = 0; i < this.getMonth(); ++i) {
num += Date.daysInMonth[i];
}
return num + this.getDate() - 1;
}
Date.prototype.getWeekOfYear = function() {
// Skip to Thursday of this week
var now = this.getDayOfYear() + (4 - this.getDay());
// Find the first Thursday of the year
var jan1 = new Date(this.getFullYear(), 0, 1);
var then = (7 - jan1.getDay() + 4);
document.write(then);
return String.leftPad(((now - then) / 7) + 1, 2, "0");
}
Date.prototype.isLeapYear = function() {
var year = this.getFullYear();
return ((year & 3) == 0 && (year % 100 || (year % 400 == 0 && year)));
}
Date.prototype.getFirstDayOfMonth = function() {
var day = (this.getDay() - (this.getDate() - 1)) % 7;
return (day < 0) ? (day + 7) : day;
}
Date.prototype.getLastDayOfMonth = function() {
var day = (this.getDay() + (Date.daysInMonth[this.getMonth()] - this.getDate())) % 7;
return (day < 0) ? (day + 7) : day;
}
Date.prototype.getDaysInMonth = function() {
Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
return Date.daysInMonth[this.getMonth()];
}
Date.prototype.getSuffix = function() {
switch (this.getDate()) {
case 1:
case 21:
case 31:
return "st";
case 2:
case 22:
return "nd";
case 3:
case 23:
return "rd";
default:
return "th";
}
}
String.escape = function(string) {
return string.replace(/('|\\)/g, "\\$1");
}
String.leftPad = function (val, size, ch) {
var result = new String(val);
if (ch == null) {
ch = " ";
}
while (result.length < size) {
result = ch + result;
}
return result;
}
Date.daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31];
Date.monthNames =
["January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"];
Date.dayNames =
["Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"];
Date.y2kYear = 50;
Date.monthNumbers = {
Jan:0,
Feb:1,
Mar:2,
Apr:3,
May:4,
Jun:5,
Jul:6,
Aug:7,
Sep:8,
Oct:9,
Nov:10,
Dec:11};
Date.patterns = {
ISO8601LongPattern:"Y-m-d H:i:s",
ISO8601ShortPattern:"Y-m-d",
ShortDatePattern: "n/j/Y",
LongDatePattern: "l, F d, Y",
FullDateTimePattern: "l, F d, Y g:i:s A",
MonthDayPattern: "F d",
ShortTimePattern: "g:i A",
LongTimePattern: "g:i:s A",
SortableDateTimePattern: "Y-m-d\\TH:i:s",
UniversalSortableDateTimePattern: "Y-m-d H:i:sO",
YearMonthPattern: "F, Y"};
var date = new Date("1/1/2007 1:11:11");
for (i = 0; i < 4000; ++i) {
var shortFormat = date.dateFormat("Y-m-d");
var longFormat = date.dateFormat("l, F d, Y g:i:s A");
date.setTime(date.getTime() + 84266956);
}
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Двоичные данные
build/pgo/js-input/key.gif Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.1 KiB

Просмотреть файл

@ -0,0 +1,145 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider math-cordic</title>
</head>
<body>
<h3>math-cordic</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
/*
* Copyright (C) Rich Moore. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/////. Start CORDIC
var AG_CONST = 0.6072529350;
function FIXED(X)
{
return X * 65536.0;
}
function FLOAT(X)
{
return X / 65536.0;
}
function DEG2RAD(X)
{
return 0.017453 * (X);
}
var Angles = [
FIXED(45.0), FIXED(26.565), FIXED(14.0362), FIXED(7.12502),
FIXED(3.57633), FIXED(1.78991), FIXED(0.895174), FIXED(0.447614),
FIXED(0.223811), FIXED(0.111906), FIXED(0.055953),
FIXED(0.027977)
];
function cordicsincos() {
var X;
var Y;
var TargetAngle;
var CurrAngle;
var Step;
X = FIXED(AG_CONST); /* AG_CONST * cos(0) */
Y = 0; /* AG_CONST * sin(0) */
TargetAngle = FIXED(28.027);
CurrAngle = 0;
for (Step = 0; Step < 12; Step++) {
var NewX;
if (TargetAngle > CurrAngle) {
NewX = X - (Y >> Step);
Y = (X >> Step) + Y;
X = NewX;
CurrAngle += Angles[Step];
} else {
NewX = X + (Y >> Step);
Y = -(X >> Step) + Y;
X = NewX;
CurrAngle -= Angles[Step];
}
}
}
///// End CORDIC
function cordic( runs ) {
var start = new Date();
for ( var i = 0 ; i < runs ; i++ ) {
cordicsincos();
}
var end = new Date();
return end.getTime() - start.getTime();
}
cordic(25000);
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,83 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider math-partial-sums</title>
</head>
<body>
<h3>math-partial-sums</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
// The Computer Language Shootout
// http://shootout.alioth.debian.org/
// contributed by Isaac Gouy
function partial(n){
var a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = 0.0;
var twothirds = 2.0/3.0;
var alt = -1.0;
var k2 = k3 = sk = ck = 0.0;
for (var k = 1; k <= n; k++){
k2 = k*k;
k3 = k2*k;
sk = Math.sin(k);
ck = Math.cos(k);
alt = -alt;
a1 += Math.pow(twothirds,k-1);
a2 += Math.pow(k,-0.5);
a3 += 1.0/(k*(k+1.0));
a4 += 1.0/(k3 * sk*sk);
a5 += 1.0/(k3 * ck*ck);
a6 += 1.0/k;
a7 += 1.0/k2;
a8 += alt/k;
a9 += alt/(2*k -1);
}
}
for (var i = 1024; i <= 16384; i *= 2) {
partial(i);
}
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,101 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider math-spectral-norm</title>
</head>
<body>
<h3>math-spectral-norm</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
// The Great Computer Language Shootout
// http://shootout.alioth.debian.org/
//
// contributed by Ian Osgood
function A(i,j) {
return 1/((i+j)*(i+j+1)/2+i+1);
}
function Au(u,v) {
for (var i=0; i<u.length; ++i) {
var t = 0;
for (var j=0; j<u.length; ++j)
t += A(i,j) * u[j];
v[i] = t;
}
}
function Atu(u,v) {
for (var i=0; i<u.length; ++i) {
var t = 0;
for (var j=0; j<u.length; ++j)
t += A(j,i) * u[j];
v[i] = t;
}
}
function AtAu(u,v,w) {
Au(u,w);
Atu(w,v);
}
function spectralnorm(n) {
var i, u=[], v=[], w=[], vv=0, vBv=0;
for (i=0; i<n; ++i) {
u[i] = 1; v[i] = w[i] = 0;
}
for (i=0; i<10; ++i) {
AtAu(u,v,w);
AtAu(v,u,w);
}
for (i=0; i<n; ++i) {
vBv += u[i]*v[i];
vv += v[i]*v[i];
}
return Math.sqrt(vBv/vv);
}
for (var i = 6; i <= 48; i *= 2) {
spectralnorm(i);
}
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,185 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider string-base64</title>
</head>
<body>
<h3>string-base64</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla XML-RPC Client component.
*
* The Initial Developer of the Original Code is
* Digital Creations 2, Inc.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Martijn Pieters <mj@digicool.com> (original author)
* Samuel Sieb <samuel@sieb.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// From: http://lxr.mozilla.org/mozilla/source/extensions/xml-rpc/src/nsXmlRpcClient.js#956
/* Convert data (an array of integers) to a Base64 string. */
var toBase64Table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var base64Pad = '=';
function toBase64(data) {
var result = '';
var length = data.length;
var i;
// Convert every three bytes to 4 ascii characters.
for (i = 0; i < (length - 2); i += 3) {
result += toBase64Table[data[i] >> 2];
result += toBase64Table[((data[i] & 0x03) << 4) + (data[i+1] >> 4)];
result += toBase64Table[((data[i+1] & 0x0f) << 2) + (data[i+2] >> 6)];
result += toBase64Table[data[i+2] & 0x3f];
}
// Convert the remaining 1 or 2 bytes, pad out to 4 characters.
if (length%3) {
i = length - (length%3);
result += toBase64Table[data[i] >> 2];
if ((length%3) == 2) {
result += toBase64Table[((data[i] & 0x03) << 4) + (data[i+1] >> 4)];
result += toBase64Table[(data[i+1] & 0x0f) << 2];
result += base64Pad;
} else {
result += toBase64Table[(data[i] & 0x03) << 4];
result += base64Pad + base64Pad;
}
}
return result;
}
/* Convert Base64 data to a string */
var toBinaryTable = [
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63,
52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1, 0,-1,-1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14,
15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1,
-1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1
];
function base64ToString(data) {
var result = '';
var leftbits = 0; // number of bits decoded, but yet to be appended
var leftdata = 0; // bits decoded, but yet to be appended
// Convert one by one.
for (var i = 0; i < data.length; i++) {
var c = toBinaryTable[data.charCodeAt(i) & 0x7f];
var padding = (data[i] == base64Pad);
// Skip illegal characters and whitespace
if (c == -1) continue;
// Collect data into leftdata, update bitcount
leftdata = (leftdata << 6) | c;
leftbits += 6;
// If we have 8 or more bits, append 8 bits to the result
if (leftbits >= 8) {
leftbits -= 8;
// Append if not padding.
if (!padding)
result += String.fromCharCode((leftdata >> leftbits) & 0xff);
leftdata &= (1 << leftbits) - 1;
}
}
// If there are any bits left, the base64 string was corrupted
if (leftbits)
throw Components.Exception('Corrupted base64 string');
return result;
}
var str = "";
for ( var i = 0; i < 8192; i++ )
str += String.fromCharCode( (25 * Math.random()) + 97 );
for ( var i = 8192; i <= 16384; i *= 2 ) {
var base64;
base64 = toBase64(str);
base64ToString(base64);
// Double the string
str += str;
}
toBinaryTable = null;
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,135 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider string-fasta</title>
</head>
<body>
<h3>string-fasta</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
// The Great Computer Language Shootout
// http://shootout.alioth.debian.org
//
// Contributed by Ian Osgood
var last = 42, A = 3877, C = 29573, M = 139968;
function rand(max) {
last = (last * A + C) % M;
return max * last / M;
}
var ALU =
"GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" +
"GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" +
"CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" +
"ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" +
"GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" +
"AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" +
"AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA";
var IUB = {
a:0.27, c:0.12, g:0.12, t:0.27,
B:0.02, D:0.02, H:0.02, K:0.02,
M:0.02, N:0.02, R:0.02, S:0.02,
V:0.02, W:0.02, Y:0.02
}
var HomoSap = {
a: 0.3029549426680,
c: 0.1979883004921,
g: 0.1975473066391,
t: 0.3015094502008
}
function makeCumulative(table) {
var last = null;
for (var c in table) {
if (last) table[c] += table[last];
last = c;
}
}
function fastaRepeat(n, seq) {
var seqi = 0, lenOut = 60;
while (n>0) {
if (n<lenOut) lenOut = n;
if (seqi + lenOut < seq.length) {
ret = seq.substring(seqi, seqi+lenOut);
seqi += lenOut;
} else {
var s = seq.substring(seqi);
seqi = lenOut - s.length;
ret = s + seq.substring(0, seqi);
}
n -= lenOut;
}
}
function fastaRandom(n, table) {
var line = new Array(60);
makeCumulative(table);
while (n>0) {
if (n<line.length) line = new Array(n);
for (var i=0; i<line.length; i++) {
var r = rand(1);
for (var c in table) {
if (r < table[c]) {
line[i] = c;
break;
}
}
}
ret = line.join('');
n -= line.length;
}
}
var ret;
var count = 7;
ret = fastaRepeat(2*count*100000, ALU);
ret = fastaRandom(3*count*1000, IUB);
ret = fastaRandom(5*count*1000, HomoSap);
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -0,0 +1,139 @@
<!DOCTYPE html>
<head>
<!--
Copyright (C) 2007 Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>SunSpider string-validate-input</title>
</head>
<body>
<h3>string-validate-input</h3>
<div id="console">
</div>
<script>
var _sunSpiderStartDate = new Date();
letters = new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
numbers = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26);
colors = new Array("FF","CC","99","66","33","00");
var endResult;
function doTest()
{
endResult = "";
// make up email address
for (var k=0;k<4000;k++)
{
name = makeName(6);
(k%2)?email=name+"@mac.com":email=name+"(at)mac.com";
// validate the email address
var pattern = /^[a-zA-Z0-9\-\._]+@[a-zA-Z0-9\-_]+(\.?[a-zA-Z0-9\-_]*)\.[a-zA-Z]{2,3}$/;
if(pattern.test(email))
{
var r = email + " appears to be a valid email address.";
addResult(r);
}
else
{
r = email + " does NOT appear to be a valid email address.";
addResult(r);
}
}
// make up ZIP codes
for (var s=0;s<4000;s++)
{
var zipGood = true;
var zip = makeNumber(4);
(s%2)?zip=zip+"xyz":zip=zip.concat("7");
// validate the zip code
for (var i = 0; i < zip.length; i++) {
var ch = zip.charAt(i);
if (ch < "0" || ch > "9") {
zipGood = false;
r = zip + " contains letters.";
addResult(r);
}
}
if (zipGood && zip.length>5)
{
zipGood = false;
r = zip + " is longer than five characters.";
addResult(r);
}
if (zipGood)
{
r = zip + " appears to be a valid ZIP code.";
addResult(r);
}
}
}
function makeName(n)
{
var tmp = "";
for (var i=0;i<n;i++)
{
var l = Math.floor(26*Math.random());
tmp += letters[l];
}
return tmp;
}
function makeNumber(n)
{
var tmp = "";
for (var i=0;i<n;i++)
{
var l = Math.floor(9*Math.random());
tmp = tmp.concat(l);
}
return tmp;
}
function addResult(r)
{
endResult += "\n" + r;
}
doTest();
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
document.getElementById("console").innerHTML = _sunSpiderInterval;
</script>
</body>
</html>

Двоичные данные
build/pgo/js-input/valid-xhtml10.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.4 KiB

Просмотреть файл

@ -73,6 +73,9 @@ if __name__ == '__main__':
browserEnv["LD_LIBRARY_PATH"] = os.path.join(SCRIPT_DIR, automation.DIST_BIN)
browserEnv["MOZILLA_FIVE_HOME"] = os.path.join(SCRIPT_DIR, automation.DIST_BIN)
automation.runApp("http://localhost:%d/index.html" % PORT, browserEnv,
os.path.join(SCRIPT_DIR, automation.DEFAULT_APP),
PROFILE_DIRECTORY, ())
url = "http://localhost:%d/index.html" % PORT
appPath = os.path.join(SCRIPT_DIR, automation.DEFAULT_APP)
(status, start) = automation.runApp(url, browserEnv, appPath,
PROFILE_DIRECTORY, {})
sys.exit(status)

Просмотреть файл

@ -1,136 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Automated Testing Code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Bob Clary <bob@bclary.com>
* Jeff Walden <jwalden+code@mit.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
From mozilla/toolkit/content
These files did not have a license
*/
function quitHook()
{
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://" + location.host + "/server/shutdown", true);
xhr.onreadystatechange = function (event)
{
if (xhr.readyState == 4)
goQuitApplication();
};
xhr.send(null);
}
function canQuitApplication()
{
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
if (!os)
{
return true;
}
try
{
var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
.createInstance(Components.interfaces.nsISupportsPRBool);
os.notifyObservers(cancelQuit, "quit-application-requested", null);
// Something aborted the quit process.
if (cancelQuit.data)
{
return false;
}
}
catch (ex)
{
}
return true;
}
function goQuitApplication()
{
const privs = 'UniversalXPConnect';
try
{
netscape.security.PrivilegeManager.enablePrivilege(privs);
}
catch(ex)
{
throw('goQuitApplication: privilege failure ' + ex);
}
if (!canQuitApplication())
{
return false;
}
const kAppStartup = '@mozilla.org/toolkit/app-startup;1';
const kAppShell = '@mozilla.org/appshell/appShellService;1';
var appService;
var forceQuit;
if (kAppStartup in Components.classes)
{
appService = Components.classes[kAppStartup].
getService(Components.interfaces.nsIAppStartup);
forceQuit = Components.interfaces.nsIAppStartup.eForceQuit;
}
else if (kAppShell in Components.classes)
{
appService = Components.classes[kAppShell].
getService(Components.interfaces.nsIAppShellService);
forceQuit = Components.interfaces.nsIAppShellService.eForceQuit;
}
else
{
throw 'goQuitApplication: no AppStartup/appShell';
}
try
{
appService.quit(forceQuit);
}
catch(ex)
{
throw('goQuitApplication: ' + ex);
}
return true;
}

Просмотреть файл

@ -355,8 +355,8 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?"""
if options.fatalAssertions:
browserEnv["XPCOM_DEBUG_BREAK"] = "stack-and-abort"
start = automation.runApp(testURL, browserEnv, options.app, PROFILE_DIRECTORY,
options.browserArgs)
(status, start) = automation.runApp(testURL, browserEnv, options.app,
PROFILE_DIRECTORY, options.browserArgs)
# Server's no longer needed, and perhaps more importantly, anything it might
# spew to console shouldn't disrupt the leak information table we print next.