Math.ceil10(55, 2) returns 100 where 2 expresses an exponent for 10^2. Besides of logarithmic adjustment we can use modulo based adjustment. It is almost the same as above but uses an arbitrary number for adjustment.
Math.ceil10(55, 2) returns 100 where 2 expresses an exponent for 10^2. .gz/.bz2 files is available.
Date.parse. Отличие заключается в том, что корректно обрабатывает строки, содержащие миллисекунды.
IWebBrowser2 (ссылка: IWebBrowser2 Interface). Объект хранит в себе данные даже после завершения всех скриптов, практически как буфер обмена, и может служить как средство обмена данными и объектами между скриптами.
var original = 'string with guillemets (standard quotation marks in Russia) « and »'; // do something to convert the original string to applicable characters var entities = ...; // insert the resulting string to the DOM var textNode = document.createTextNode(entities);Найденное решение [2] видимо очень известно во всем интернете. Однако это решение нам показалось не оптимально - довольно громоздкий код, который циклически перебирает и заменяет программно заданный набор сущностей. И этот код не использует внутренние возможности самого браузера - ведь браузер делает это автоматически. Но решение было найдено [3]. Этот код полностью нас удовлетворял - он очень мал, использует встроенные возможности и не содержит жестко заданного набора конвертируемых сущностей. Параллельно мы нашли решение для обратной задачи - перевод символов в их сущности [4].
CMD/BAT only. It accepts three arguments: the name of a variable to store the resulting string, the multiplier (number of time the input string should be repeated), and the input string.
CMD.EXE features. After that here (in Russian too) i have simplified this way until two lines of a code. But both ways are platform-dependent - the order of date parts depends on the locale settings.
CMD.EXE, the command line interpreter in Windows, does not allows to collect favorite scripts under appropriate folders and use them multiple times in the future. So we have to use the "copy-and-paste" technology to migrate some needed functionalities from one script to another.
String. Of course, it has own shortcomings but in the most cases it covers the wide range of URLs and protocols (http(s), ftp, mailto, etc; the mandatory part of URL, host is considered as domain names, IPs, and localhost separately), and moreover it considers the more complex URLs like jdbc:oracle://localhost:1521.
@echo off
if "%~1" == "" (
echo EMPTY
goto :EOF
)
if "%~1" == "0" (
echo ZERO
goto :EOF
)
set /a number_var=%~1 2>nul
if errorlevel 2 (
echo ILLEGAL
goto :EOF
)
if %~1 neq %number_var% (
echo ERROR
goto :EOF
)
set number_var
goto :EOF
var n = 1000;
var start = (new Date()).getTime();/
for (var i = 0 ; i < n; i++) {
// bla-bla-bla ...
}
var stop = (new Date()).getTime();
var duration = stop - start;
var average = duration / n;
document.writeln(average);
I can presume that all the familiar lines such as these. I may be interested in the performance of a function or method, and possibly, some of program. But I do not want to pollute my working project by some kind of garbage, such as this. Also I do not want this for function that I am trying to estimate - what algorithm is better.
n and ending by line m.
var arr = [100, 200, 300, 400];
var result = 0;
for (var i = 0; i < arr.length; i++) {
result += arr[i];
}
can be transformed to the next
var arr = [100, 200, 300, 400];
((function()
{
var result = 0;
for (var i = 0; i < arr.length; i++) {
result += arr[i];
}
})();
Function.prototype.eval = function()This method is defined for internal object
Function, it is a certain amount of times, while retaining the length function and prints some statistics about the performance.
var arr = [1, 2, 3, 4];
function sum(arr)
{
var result = 0;
for (var i = 0; i < arr.length; i++) {
result += arr[i];
}
return result;
}
// original code
var s = sum(arr);
// modified code
var s = sum.eval(arr);
When comparing the original and modified codes, it can be seen that a difference is minimal. The code is pure until now and the result allows analyzing of information.
Function.prototype.evalCount - integer parameter keeps the number of iterations, by default is1000. Function.prototype.evalDuration - integer parameter keeps duration of the code execution. It is evaluated during a benchmarking process and does not have default value.Function.prototype.evalPrint = function() - auxiliary function for output of statistics of the performance. It takes in account differences of environments and launches appropriate output method. By default, it outputs the number of iterations and duration. sum.evalCount = 10240; // 10K iterations var result = sum.eval(1, 2, 3, 4);
var n = 1000;
var start = (new Date()).getTime();/
for (var i = 0 ; i < n; i++) {
// bla-bla-bla ...
}
var stop = (new Date()).getTime();
var duration = stop - start;
var average = duration / n;
document.writeln(average);
Думаю, всем знакомы строчки, подобные этим. Меня может интересовать производительность функции или метода, а возможно и некоторого участка программы. Но я не хочу засорять свой еще сырой код всяким мусором, подобным этому. Я также не хочу это делать для функций, когда пытаюсь оценить - какой же алгоритм лучше.
n и заканчивая строкой m.
var arr = [100, 200, 300, 400];
var result = 0;
for (var i = 0; i < arr.length; i++) {
result += arr[i];
}
может быть преобразован в следующий
var arr = [100, 200, 300, 400];
((function()
{
var result = 0;
for (var i = 0; i < arr.length; i++) {
result += arr[i];
}
})();
Function.prototype.eval = function()Данный метод определен для встроенного объекта
Function, вызывает его определенное количество раз, при этом запоминает длительность выполнения функции и печатает некоторую статистическую информацию о ходе выполнения.
var arr = [1, 2, 3, 4];
function sum(arr)
{
var result = 0;
for (var i = 0; i < arr.length; i++) {
result += arr[i];
}
return result;
}
// исходный код
var s = sum(arr);
// модифицированный код
var s = sum.eval(arr);
То есть, сравнивая исходный и модифицированный код, можно увидеть, что отличия минимальны. Код по прежнему чист, а результат позволяет проанализировать полученную информацию.
Function.prototype.evalCount - целочисленный параметр хранит количество итераций, или количество раз исполнения кода, значение по умолчанию 1000. Function.prototype.evalDuration - целочисленный параметр хранит продолжительность выполнения кода. Function.prototype.evalPrint = function() - вспомогательная функция для вывода статистики о производительности, учитывает различия сред исполнения и вызывает соответствующий метод для вывода количества итераций и продолжительности исполнения кода.
Function.prototype.evalDuration вычисляется в процессе и не имеет значения по умолчанию.
sum.evalCount = 10240; // 10K iterations var result = sum.eval(1, 2, 3, 4);