Free basic version

This commit is contained in:
AB
2019-09-12 00:03:58 +03:00
parent e2ba2c900e
commit 1dcd90ab28
30 changed files with 5729 additions and 3 deletions

BIN
a.out Executable file

Binary file not shown.

20
counter.bas Normal file
View File

@ -0,0 +1,20 @@
#define floor(x) ((x*2.0-0.5)shr 1)
Dim last As Long
Dim As Long num, digit, sum, start, end_
start = 0
end_ = 1000000
repeat:
If start < end_ Then
num = end_
Do
If num = 0 Then Exit Do
digit = num Mod 10
sum = sum + digit
num = floor(num / 10)
Loop
end_ = end_ - 1
Goto repeat
End If
Print sum

8
new_sum.py Normal file
View File

@ -0,0 +1,8 @@
num = 123
res = 0
while num > 0:
res = res + num % 10
num = int(num / 10)
print(res)

BIN
sum.bin Executable file

Binary file not shown.

BIN
sum.build/.sconsign.dblite Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
sum.build/InspectPatcher.o Normal file

Binary file not shown.

BIN
sum.build/MainProgram.o Normal file

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,2 @@
Final result is %dtimesys/home/ab/repos/sum_counter/sum.pyproc # | from | till | summ | elapsed time per childdictstartthread_countshiftmanagerreturn_dictjobst_startt_endvaluevaluesFound %s CPUs. Going to spawn %s forks.ssProcessargsprocess_timecpu_counttargetsumumatoru_kunnumbereedigitelapsed_time %s |%10d |%10d |%10d | %6.2fManager--------------------------------------------------------------------------------<module>appendmultiprocessingjoin__annotations__rbintlenfileiternameopenreprsendsitetypebytescloselevelprintrangethrowtypesformatlocals__all____cmp____doc__compileglobalsinspect__dict____exit____file____iter____main____name____path____spec__fromlist__class____enter__bytearray__cached____import____loader____module____package__classmethod__builtins__staticmethod__metaclass___initializing__class_getitem__/usr/bin/python

176
sum.build/__constants.c Normal file
View File

@ -0,0 +1,176 @@
#include "nuitka/prelude.h"
// Sentinel PyObject to be used for all our call iterator endings. It will
// become a PyCObject pointing to NULL. It's address is unique, and that's
// enough for us to use it as sentinel value.
PyObject *_sentinel_value = NULL;
PyObject *const_int_0;
PyObject *const_str_dot;
PyObject *const_int_pos_1;
PyObject *const_str_empty;
PyObject *const_dict_empty;
PyObject *const_bytes_empty;
PyObject *const_tuple_empty;
PyObject *const_str_plain_rb;
PyObject *const_str_plain_end;
PyObject *const_str_plain_int;
PyObject *const_str_plain_len;
PyObject *const_str_plain_sum;
PyObject *const_str_plain_file;
PyObject *const_str_plain_iter;
PyObject *const_str_plain_name;
PyObject *const_str_plain_open;
PyObject *const_str_plain_read;
PyObject *const_str_plain_repr;
PyObject *const_str_plain_send;
PyObject *const_str_plain_site;
PyObject *const_str_plain_type;
PyObject *const_str_plain_bytes;
PyObject *const_str_plain_close;
PyObject *const_str_plain_level;
PyObject *const_str_plain_print;
PyObject *const_str_plain_range;
PyObject *const_str_plain_throw;
PyObject *const_str_plain_types;
PyObject *const_str_plain_format;
PyObject *const_str_plain_locals;
PyObject *const_str_plain___all__;
PyObject *const_str_plain___cmp__;
PyObject *const_str_plain___doc__;
PyObject *const_str_plain_compile;
PyObject *const_str_plain_globals;
PyObject *const_str_plain_inspect;
PyObject *const_str_plain___dict__;
PyObject *const_str_plain___exit__;
PyObject *const_str_plain___file__;
PyObject *const_str_plain___iter__;
PyObject *const_str_plain___main__;
PyObject *const_str_plain___name__;
PyObject *const_str_plain___path__;
PyObject *const_str_plain___spec__;
PyObject *const_str_plain_fromlist;
PyObject *const_str_plain___class__;
PyObject *const_str_plain___enter__;
PyObject *const_str_plain_bytearray;
PyObject *const_str_plain___cached__;
PyObject *const_str_plain___import__;
PyObject *const_str_plain___loader__;
PyObject *const_str_plain___module__;
PyObject *const_str_plain___package__;
PyObject *const_str_plain_classmethod;
PyObject *const_str_plain___builtins__;
PyObject *const_str_plain_staticmethod;
PyObject *const_str_plain___metaclass__;
PyObject *const_str_plain__initializing;
PyObject *const_str_plain___class_getitem__;
PyObject *const_str_digest_58961c73026e70b23b08cf381b49e04e;
static void _createGlobalConstants( void )
{
NUITKA_MAY_BE_UNUSED PyObject *exception_type, *exception_value;
NUITKA_MAY_BE_UNUSED PyTracebackObject *exception_tb;
#ifdef _MSC_VER
// Prevent unused warnings in case of simple programs, the attribute
// NUITKA_MAY_BE_UNUSED doesn't work for MSVC.
(void *)exception_type; (void *)exception_value; (void *)exception_tb;
#endif
const_int_0 = PyLong_FromUnsignedLong( 0ul );
const_str_dot = UNSTREAM_STRING( &constant_bin[ 57 ], 1, 0 );
const_int_pos_1 = PyLong_FromUnsignedLong( 1ul );
const_str_empty = UNSTREAM_STRING( &constant_bin[ 0 ], 0, 0 );
const_dict_empty = _PyDict_NewPresized( 0 );
assert( PyDict_Size( const_dict_empty ) == 0 );
const_bytes_empty = UNSTREAM_BYTES( &constant_bin[ 0 ], 0 );
const_tuple_empty = PyTuple_New( 0 );
const_str_plain_rb = UNSTREAM_STRING( &constant_bin[ 465 ], 2, 1 );
const_str_plain_end = UNSTREAM_STRING( &constant_bin[ 169 ], 3, 1 );
const_str_plain_int = UNSTREAM_STRING( &constant_bin[ 467 ], 3, 1 );
const_str_plain_len = UNSTREAM_STRING( &constant_bin[ 470 ], 3, 1 );
const_str_plain_sum = UNSTREAM_STRING( &constant_bin[ 42 ], 3, 1 );
const_str_plain_file = UNSTREAM_STRING( &constant_bin[ 473 ], 4, 1 );
const_str_plain_iter = UNSTREAM_STRING( &constant_bin[ 477 ], 4, 1 );
const_str_plain_name = UNSTREAM_STRING( &constant_bin[ 481 ], 4, 1 );
const_str_plain_open = UNSTREAM_STRING( &constant_bin[ 485 ], 4, 1 );
const_str_plain_read = UNSTREAM_STRING( &constant_bin[ 123 ], 4, 1 );
const_str_plain_repr = UNSTREAM_STRING( &constant_bin[ 489 ], 4, 1 );
const_str_plain_send = UNSTREAM_STRING( &constant_bin[ 493 ], 4, 1 );
const_str_plain_site = UNSTREAM_STRING( &constant_bin[ 497 ], 4, 1 );
const_str_plain_type = UNSTREAM_STRING( &constant_bin[ 501 ], 4, 1 );
const_str_plain_bytes = UNSTREAM_STRING( &constant_bin[ 505 ], 5, 1 );
const_str_plain_close = UNSTREAM_STRING( &constant_bin[ 510 ], 5, 1 );
const_str_plain_level = UNSTREAM_STRING( &constant_bin[ 515 ], 5, 1 );
const_str_plain_print = UNSTREAM_STRING( &constant_bin[ 520 ], 5, 1 );
const_str_plain_range = UNSTREAM_STRING( &constant_bin[ 525 ], 5, 1 );
const_str_plain_throw = UNSTREAM_STRING( &constant_bin[ 530 ], 5, 1 );
const_str_plain_types = UNSTREAM_STRING( &constant_bin[ 535 ], 5, 1 );
const_str_plain_format = UNSTREAM_STRING( &constant_bin[ 540 ], 6, 1 );
const_str_plain_locals = UNSTREAM_STRING( &constant_bin[ 546 ], 6, 1 );
const_str_plain___all__ = UNSTREAM_STRING( &constant_bin[ 552 ], 7, 1 );
const_str_plain___cmp__ = UNSTREAM_STRING( &constant_bin[ 559 ], 7, 1 );
const_str_plain___doc__ = UNSTREAM_STRING( &constant_bin[ 566 ], 7, 1 );
const_str_plain_compile = UNSTREAM_STRING( &constant_bin[ 573 ], 7, 1 );
const_str_plain_globals = UNSTREAM_STRING( &constant_bin[ 580 ], 7, 1 );
const_str_plain_inspect = UNSTREAM_STRING( &constant_bin[ 587 ], 7, 1 );
const_str_plain___dict__ = UNSTREAM_STRING( &constant_bin[ 594 ], 8, 1 );
const_str_plain___exit__ = UNSTREAM_STRING( &constant_bin[ 602 ], 8, 1 );
const_str_plain___file__ = UNSTREAM_STRING( &constant_bin[ 610 ], 8, 1 );
const_str_plain___iter__ = UNSTREAM_STRING( &constant_bin[ 618 ], 8, 1 );
const_str_plain___main__ = UNSTREAM_STRING( &constant_bin[ 626 ], 8, 1 );
const_str_plain___name__ = UNSTREAM_STRING( &constant_bin[ 634 ], 8, 1 );
const_str_plain___path__ = UNSTREAM_STRING( &constant_bin[ 642 ], 8, 1 );
const_str_plain___spec__ = UNSTREAM_STRING( &constant_bin[ 650 ], 8, 1 );
const_str_plain_fromlist = UNSTREAM_STRING( &constant_bin[ 658 ], 8, 1 );
const_str_plain___class__ = UNSTREAM_STRING( &constant_bin[ 666 ], 9, 1 );
const_str_plain___enter__ = UNSTREAM_STRING( &constant_bin[ 675 ], 9, 1 );
const_str_plain_bytearray = UNSTREAM_STRING( &constant_bin[ 684 ], 9, 1 );
const_str_plain___cached__ = UNSTREAM_STRING( &constant_bin[ 693 ], 10, 1 );
const_str_plain___import__ = UNSTREAM_STRING( &constant_bin[ 703 ], 10, 1 );
const_str_plain___loader__ = UNSTREAM_STRING( &constant_bin[ 713 ], 10, 1 );
const_str_plain___module__ = UNSTREAM_STRING( &constant_bin[ 723 ], 10, 1 );
const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 733 ], 11, 1 );
const_str_plain_classmethod = UNSTREAM_STRING( &constant_bin[ 744 ], 11, 1 );
const_str_plain___builtins__ = UNSTREAM_STRING( &constant_bin[ 755 ], 12, 1 );
const_str_plain_staticmethod = UNSTREAM_STRING( &constant_bin[ 767 ], 12, 1 );
const_str_plain___metaclass__ = UNSTREAM_STRING( &constant_bin[ 779 ], 13, 1 );
const_str_plain__initializing = UNSTREAM_STRING( &constant_bin[ 792 ], 13, 1 );
const_str_plain___class_getitem__ = UNSTREAM_STRING( &constant_bin[ 805 ], 17, 1 );
const_str_digest_58961c73026e70b23b08cf381b49e04e = UNSTREAM_STRING( &constant_bin[ 822 ], 15, 0 );
#if _NUITKA_EXE
/* Set the "sys.executable" path to the original CPython executable. */
PySys_SetObject(
(char *)"executable",
const_str_digest_58961c73026e70b23b08cf381b49e04e
);
#endif
}
// In debug mode we can check that the constants were not tampered with in any
// given moment. We typically do it at program exit, but we can add extra calls
// for sanity.
#ifndef __NUITKA_NO_ASSERT__
void checkGlobalConstants( void )
{
}
#endif
void createGlobalConstants( void )
{
if ( _sentinel_value == NULL )
{
#if PYTHON_VERSION < 300
_sentinel_value = PyCObject_FromVoidPtr( NULL, NULL );
#else
// The NULL value is not allowed for a capsule, so use something else.
_sentinel_value = PyCapsule_New( (void *)27, "sentinel", NULL );
#endif
assert( _sentinel_value );
_createGlobalConstants();
}
}

BIN
sum.build/__constants.o Normal file

Binary file not shown.

42
sum.build/__frozen.c Normal file
View File

@ -0,0 +1,42 @@
// This provides the frozen (compiled bytecode) files that are included if
// any.
#include <Python.h>
#include "nuitka/constants_blob.h"
// Blob from which modules are unstreamed.
#define stream_data constant_bin
// These modules should be loaded as bytecode. They may e.g. have to be loadable
// during "Py_Initialize" already, or for irrelevance, they are only included
// in this un-optimized form. These are not compiled by Nuitka, and therefore
// are not accelerated at all, merely bundled with the binary or module, so
// that CPython library can start out finding them.
struct frozen_desc {
char const *name;
ssize_t start;
int size;
};
void copyFrozenModulesTo( struct _frozen *destination )
{
struct frozen_desc frozen_modules[] = {
{ NULL, 0, 0 }
};
struct frozen_desc *current = frozen_modules;
for(;;)
{
destination->name = (char *)current->name;
destination->code = (unsigned char *)&constant_bin[ current->start ];
destination->size = current->size;
if (destination->name == NULL) break;
current += 1;
destination += 1;
};
}

BIN
sum.build/__frozen.o Normal file

Binary file not shown.

1807
sum.build/__helpers.c Normal file

File diff suppressed because it is too large Load Diff

9
sum.build/__helpers.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef __NUITKA_CALLS_H__
#define __NUITKA_CALLS_H__
extern PyObject *CALL_FUNCTION_WITH_ARGS1( PyObject *called, PyObject **args );
extern PyObject *CALL_FUNCTION_WITH_ARGS2( PyObject *called, PyObject **args );
extern PyObject *CALL_FUNCTION_WITH_ARGS3( PyObject *called, PyObject **args );
extern PyObject *CALL_FUNCTION_WITH_ARGS4( PyObject *called, PyObject **args );
extern PyObject *CALL_FUNCTION_WITH_ARGS5( PyObject *called, PyObject **args );
#endif

BIN
sum.build/__helpers.o Normal file

Binary file not shown.

View File

3609
sum.build/module.__main__.c Normal file

File diff suppressed because it is too large Load Diff

BIN
sum.build/module.__main__.o Normal file

Binary file not shown.

View File

@ -0,0 +1,52 @@
AS=as
ASCOM=$AS $ASFLAGS -o $TARGET $SOURCES
ASPPCOM=$CC $ASPPFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES
ASPPFLAGS=$ASFLAGS
CC=gcc
CCCOM=$CC -o $TARGET -c $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES
CCVERSION=8.2.1
CFILESUFFIX=.c
CPPDEFPREFIX=-D
CPPDEFSUFFIX=
CXX=g++
CXXCOM=$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCES
CXXFILESUFFIX=.cc
CXXVERSION=8.2.1
INCPREFIX=-I
INCSUFFIX=
LDMODULE=$SHLINK
LDMODULECOM=$LDMODULE -o $TARGET $LDMODULEFLAGS $__LDMODULEVERSIONFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS
LDMODULEFLAGS=$SHLINKFLAGS
LDMODULENOVERSIONSYMLINKS=$SHLIBNOVERSIONSYMLINKS
LDMODULEPREFIX=$SHLIBPREFIX
LDMODULESUFFIX=$SHLIBSUFFIX
LDMODULEVERSION=$SHLIBVERSION
LDMODULEVERSIONFLAGS=$SHLIBVERSIONFLAGS
LIBDIRPREFIX=-L
LIBDIRSUFFIX=
LIBLINKPREFIX=-l
LIBLINKSUFFIX=
LIBPREFIX=lib
LIBSUFFIX=.a
LINK=$SMARTLINK
LINKCOM=$LINK -o $TARGET $LINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS
OBJPREFIX=
OBJSUFFIX=.o
PLATFORM=posix
PROGPREFIX=
PROGSUFFIX=
RPATHPREFIX=-Wl,-rpath=
RPATHSUFFIX=
SHCC=$CC
SHCCCOM=$SHCC -o $TARGET -c $SHCFLAGS $SHCCFLAGS $_CCCOMCOM $SOURCES
SHCXX=$CXX
SHCXXCOM=$SHCXX -o $TARGET -c $SHCXXFLAGS $SHCCFLAGS $_CCCOMCOM $SOURCES
SHELL=sh
SHLIBPREFIX=
SHLIBSUFFIX=.so
SHLINK=$LINK
SHLINKCOM=$SHLINK -o $TARGET $SHLINKFLAGS $__SHLIBVERSIONFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS
SHOBJPREFIX=$OBJPREFIX
SHOBJSUFFIX=.os
TARGET_ARCH=x86_64
TEMPFILEPREFIX=@

5
sum.c
View File

@ -1,6 +1,6 @@
// Maximum performance with optimal count of forks.
// HOW TO BUILD
// gcc summ.c -lpthread
// gcc sum.c -lpthread
#include <stdio.h>
#include <stdlib.h>
#include <sys/sysinfo.h>
@ -35,7 +35,8 @@ int main(int argc, char *argv[])
{
long end, start, first, last, shift, i, temp;
int p_pid = getpid();
long f_count = 2 * get_nprocs_conf();
long f_count = 3 * get_nprocs_conf();
// long f_count = 1;
pid_t pid;
main_result = mmap(NULL, sizeof *main_result,
PROT_READ | PROT_WRITE,

2
sum.py
View File

@ -23,7 +23,7 @@ def sumumatoru_kun(start, end, number, return_dict):
def summ():
start = 0
end = 10000000
end = 100000000
thread_count = multiprocessing.cpu_count() * 2
shift = int((end - start) / thread_count)