Sponsored Content
Top Forums Shell Programming and Scripting Display-performance in terminal, bash or python? Post 302905446 by Corona688 on Wednesday 11th of June 2014 03:07:40 PM
Old 06-11-2014
Let's see the difference between what bash and python do when you tell them to do nothing:

Code:
$ strace bash 2>&1 </dev/null | grep "^open"

open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libreadline.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libncurses.so.5", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/dev/tty", O_RDWR|O_NONBLOCK)     = 3
open("/usr/lib64/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
open("/proc/meminfo", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib64/gconv/gconv-modules.cache", O_RDONLY) = 3

$ strace python 2>&1 </dev/null | grep "^open"

open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/etc/env.d/python/config", O_RDONLY) = 3
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib64/libpython3.3.so.1.0", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libutil.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib64/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib64/gconv/gconv-modules.cache", O_RDONLY) = 3
open("/dev/urandom", O_RDONLY)          = 3
open("/usr/bin/pyvenv.cfg", O_RDONLY)   = -1 ENOENT (No such file or directory)
open("/usr/pyvenv.cfg", O_RDONLY)       = -1 ENOENT (No such file or directory)
open("/proc/meminfo", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/lib64/python3.3/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/lib64/python3.3/encodings/__pycache__/__init__.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/codecs.cpython-33.pyc", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/lib64/python3.3/encodings", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/lib64/python3.3/encodings/__pycache__/aliases.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/encodings/__pycache__/utf_8.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/encodings/__pycache__/latin_1.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/io.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/abc.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/_weakrefset.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/locale.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/re.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/sre_compile.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/sre_parse.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/sre_constants.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/functools.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/collections/__pycache__/__init__.cpython-33.pyc", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/lib64/python3.3/collections", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/lib64/python3.3/collections/__pycache__/abc.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/keyword.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/heapq.cpython-33.pyc", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/lib64/python3.3/plat-linux", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/lib64/python3.3/lib-dynload", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/lib64/python3.3/lib-dynload/_heapq.cpython-33.so", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib64/python3.3/__pycache__/weakref.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/reprlib.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/copyreg.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/site.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/os.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/stat.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/posixpath.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/genericpath.cpython-33.pyc", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/lib64/python3.3", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/lib64/python3.3/__pycache__/sysconfig.cpython-33.pyc", O_RDONLY) = 3
open("/usr/lib64/python3.3/__pycache__/_sysconfigdata.cpython-33.pyc", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/lib64/python3.3/site-packages", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/lib64/python3.3/site-packages", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3

$

Python is a much bigger language -- it has to do a whole lot more to load than BASH. That doesn't mean it's slow once it's actually loaded... See how long either language takes to print 100,000 lines. I bet they'd be close to the same (since it's mostly going to be limited by I/O speed).

Python would be much better than BASH because Python will probably let you use the ncurses console library. That alone would probably make it faster for your needs -- replacing a lot of cumbersome things with simple calls.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

terminal display

I want to display a system warning message at the prompt of every live terminal on a sun solaris 8 machine using CDE. I know this can be done on a console, but what about dtterm and xterm regular windows? Does anyone know how this is done? What about a single terminal? Clear skies,... (2 Replies)
Discussion started by: seismic_willy
2 Replies

2. UNIX for Advanced & Expert Users

Understanding terminal display of (awkward) characters

Gurus, I've been on computers for a while, but I've yet to have the behind-the-scenes knowledge. I'm not sure if this is so much a Unix question as it is a nitty gritty computer one. We received a customer file which had a "funny apostrophe." When displaying the file via more, the character... (1 Reply)
Discussion started by: effigy
1 Replies

3. Shell Programming and Scripting

date and time to display on the terminal

hi all, am trying to 'grep' some text from a log file and use the 'cut' command to read from that line i just grep'ed to extract date/time and response times. code sniplet i am using is : grep -i 'text to grep' Out.log | while read LINE; do ... (11 Replies)
Discussion started by: cesarNZ
11 Replies

4. Shell Programming and Scripting

How to have color coded Terminal display,(like linux)

Hi all, I would like to know how to have a color display in the terminal... In the sense that, In many linux terminals,we have color coded for each file type, green for executable ,blue for dirs and so on... I wanted to know how i can have the same arrangement in solaris(b-79a) I am not... (5 Replies)
Discussion started by: wrapster
5 Replies

5. Windows & DOS: Issues & Discussions

Display running 'app' in terminal titlebar?

Hi. I was, not too long ago, an OS X home user. One of the things I remember from using the Apple-installed Terminal is: whenever an executable that took more than a split second to do its thing was running, its name would appear in the title bar in a way similar to "Terminal: ssh" or "Terminal:... (0 Replies)
Discussion started by: SilversleevesX
0 Replies

6. Shell Programming and Scripting

How to display message when starting a terminal

Hello all, I would like a message to be displayed on the shell when someone opens up the terminal - something like a welcome msg with date and time. I know how to do this by running the shell commands but dont know how to display it when a user opens up the terminal? Thanks in advance (27 Replies)
Discussion started by: mrudula009
27 Replies

7. UNIX for Advanced & Expert Users

Performance impact of terminal output

Hello, I am doing fluid simulations using OpenFOAM. This program produces a lot of output every time step. Producing output is surely not the most time consuming part, but I wonder whether writing output to the terminal or writing it into a file is faster. With thousands of time steps a... (1 Reply)
Discussion started by: Chuck Morris
1 Replies

8. UNIX for Advanced & Expert Users

Unix terminal display related issue

Want few input related to unix environment and terminal settings: 1. Am trying to find a way to keep the unix terminal display intact even after opening and closing a vi/less file. Currently if I open a vim file in the unix terminal and then close the file,it displays the contents of vim file on... (4 Replies)
Discussion started by: talktovkjain
4 Replies

9. Homework & Coursework Questions

Display info about users (UID GID processes terminal)

I would like to get an opinion for my solution for this task and get feedback about better approach or mistakes I have made. 1. The problem statement, all variables and given/known data: The task is to create a script which prints information about users whose names are specified in the... (2 Replies)
Discussion started by: kornfan
2 Replies

10. Shell Programming and Scripting

Convert excel to csv in python date not display exactly

Hi, Anyone can help I am just converting the excel file to csv using python, I can get the conversion output but the date not display exactly. test.xlsx date format 167 1588 risks/SCS JP CAMPANA & CIE.pdf SCS JP CAMPANA & CIE 2 1 1 0 2015-03-16 16:56:25 167 1146 risks/AirBNB... (1 Reply)
Discussion started by: fspalero
1 Replies
All times are GMT -4. The time now is 09:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy